binutils-gdb/gdbserver/remote-utils.c

1692 lines
39 KiB
C
Raw Normal View History

/* Remote utility routines for the remote server for GDB.
Copyright (C) 1986-2020 Free Software Foundation, Inc.
1999-07-07 22:19:36 +02:00
This file is part of GDB.
1999-07-07 22:19:36 +02:00
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
the Free Software Foundation; either version 3 of the License, or
1999-07-07 22:19:36 +02:00
(at your option) any later version.
1999-07-07 22:19:36 +02:00
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.
1999-07-07 22:19:36 +02:00
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "server.h"
Assume termios is available, remove support for termio and sgtty This commit garbage collects the termio and sgtty support. GDB's terminal handling code still has support for the old termio and sgtty interfaces in addition to termios. However, I think it's pretty safe to assume that for a long, long time, Unix-like systems provide termios. GNU/Linux, Solaris, Cygwin, AIX, DJGPP, macOS and the BSDs all have had termios.h for many years. Looking around the web, I found discussions about FreeBSD folks trying to get rid of old sgtty.h a decade ago: https://lists.freebsd.org/pipermail/freebsd-hackers/2007-March/019983.html So I think support for termio and sgtty in GDB is just dead code that is never compiled anywhere and is just getting in the way. For example, serial_noflush_set_tty_state and the raw<->cooked concerns mentioned in inflow.c only exist because of sgtty (see hardwire_noflush_set_tty_state). Regtested on GNU/Linux. Confirmed that I can still build Solaris, DJGPP and AIX GDB and that the resulting GDBs still include the termios.h-guarded code. Confirmed mingw-w64 GDB still builds and skips the termios.h-guarded code. gdb/ChangeLog: 2017-11-06 Pedro Alves <palves@redhat.com> * Makefile.in (SER_HARDWIRE): Update comment. (HFILES_NO_SRCDIR): Remove gdb_termios.h. * common/gdb_termios.h: Delete file. * common/job-control.c: Include termios.h and unistd.h instead of gdb_termios.h. (gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor check. (have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS. Remove sgtty code. * configure.ac: No longer check for termio.h and sgtty.h. * configure: Regenerate. * inflow.c: Include termios.h instead of gdb_termios.h. Replace PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout. Replace PROCESS_GROUP_TYPE references with pid_t references throughout. (gdb_getpgrp): Delete. (set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp. (child_terminal_inferior): Remove comment. Remove sgtty code. (child_terminal_ours_1): Use tcgetpgrp directly instead of gdb_getpgrp. Use serial_set_tty_state instead aof serial_noflush_set_tty_state. Remove sgtty code. * inflow.h: Include unistd.h instead of gdb_termios.h. Replace PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check. (inferior_process_group): Now returns pid_t. * ser-base.c (ser_base_noflush_set_tty_state): Delete. * ser-base.h (ser_base_noflush_set_tty_state): Delete. * ser-event.c (serial_event_ops): Update. * ser-go32.c (dos_noflush_set_tty_state): Delete. (dos_ops): Update. * ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update. * ser-pipe.c (pipe_ops): Update. * ser-tcp.c (tcp_ops): Update. * ser-unix.c: Include termios.h instead of gdb_termios.h. Remove HAVE_TERMIOS checks. [HAVE_TERMIO] (struct hardwire_ttystate): Delete. [HAVE_SGTTY] (struct hardwire_ttystate): Delete. (get_tty_state, set_tty_state): Drop termio and sgtty code, and assume termios. (hardwire_noflush_set_tty_state): Delete. (hardwire_print_tty_state, hardwire_drain_output) (hardwire_flush_output, hardwire_flush_input) (hardwire_send_break, hardwire_raw, hardwire_setbaudrate) (hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty code, and assume termios. (hardwire_ops): Update. (_initialize_ser_hardwire): Remove HAVE_TERMIOS check. * serial.c (serial_noflush_set_tty_state): Delete. * serial.h (serial_noflush_set_tty_state): Delete. (serial_ops::noflush_set_tty_state): Delete. gdb/gdbserver/ChangeLog: 2017-11-06 Pedro Alves <palves@redhat.com> * configure.ac: No longer check for termio.h and sgtty.h. * configure: Regenerate. * remote-utils.c: Include termios.h instead of gdb_termios.h. (remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS. Remove termio and sgtty code.
2017-11-06 16:36:46 +01:00
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
#include "target.h"
#include "gdbthread.h"
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
#include "tdesc.h"
#include "debug.h"
#include "dll.h"
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/rsp-low.h"
#include "gdbsupport/netstuff.h"
#include "gdbsupport/filestuff.h"
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
#include "gdbsupport/gdb-sigmask.h"
#include <ctype.h>
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
#if HAVE_SYS_FILE_H
#include <sys/file.h>
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
#endif
#if HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#if HAVE_NETDB_H
#include <netdb.h>
#endif
#if HAVE_NETINET_TCP_H
#include <netinet/tcp.h>
#endif
#if HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
#if HAVE_SIGNAL_H
#include <signal.h>
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
#endif
#if HAVE_FCNTL_H
#include <fcntl.h>
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
#endif
Rename common to gdbsupport This is the next patch in the ongoing series to move gdbsever to the top level. This patch just renames the "common" directory. The idea is to do this move in two parts: first rename the directory (this patch), then move the directory to the top. This approach makes the patches a bit more tractable. I chose the name "gdbsupport" for the directory. However, as this patch was largely written by sed, we could pick a new name without too much difficulty. Tested by the buildbot. gdb/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * contrib/ari/gdb_ari.sh: Change common to gdbsupport. * configure: Rebuild. * configure.ac: Change common to gdbsupport. * gdbsupport: Rename from common. * acinclude.m4: Change common to gdbsupport. * Makefile.in (CONFIG_SRC_SUBDIR, COMMON_SFILES) (HFILES_NO_SRCDIR, stamp-version, ALLDEPFILES): Change common to gdbsupport. * aarch64-tdep.c, ada-lang.c, ada-lang.h, agent.c, alloc.c, amd64-darwin-tdep.c, amd64-dicos-tdep.c, amd64-fbsd-nat.c, amd64-fbsd-tdep.c, amd64-linux-nat.c, amd64-linux-tdep.c, amd64-nbsd-tdep.c, amd64-obsd-tdep.c, amd64-sol2-tdep.c, amd64-tdep.c, amd64-windows-tdep.c, arch-utils.c, arch/aarch64-insn.c, arch/aarch64.c, arch/aarch64.h, arch/amd64.c, arch/amd64.h, arch/arm-get-next-pcs.c, arch/arm-linux.c, arch/arm.c, arch/i386.c, arch/i386.h, arch/ppc-linux-common.c, arch/riscv.c, arch/riscv.h, arch/tic6x.c, arm-tdep.c, auto-load.c, auxv.c, ax-gdb.c, ax-general.c, ax.h, breakpoint.c, breakpoint.h, btrace.c, btrace.h, build-id.c, build-id.h, c-lang.h, charset.c, charset.h, cli/cli-cmds.c, cli/cli-cmds.h, cli/cli-decode.c, cli/cli-dump.c, cli/cli-option.h, cli/cli-script.c, coff-pe-read.c, command.h, compile/compile-c-support.c, compile/compile-c.h, compile/compile-cplus-symbols.c, compile/compile-cplus-types.c, compile/compile-cplus.h, compile/compile-loc2c.c, compile/compile.c, completer.c, completer.h, contrib/ari/gdb_ari.sh, corefile.c, corelow.c, cp-support.c, cp-support.h, cp-valprint.c, csky-tdep.c, ctf.c, darwin-nat.c, debug.c, defs.h, disasm-selftests.c, disasm.c, disasm.h, dtrace-probe.c, dwarf-index-cache.c, dwarf-index-cache.h, dwarf-index-write.c, dwarf2-frame.c, dwarf2expr.c, dwarf2loc.c, dwarf2read.c, event-loop.c, event-top.c, exceptions.c, exec.c, extension.h, fbsd-nat.c, features/aarch64-core.c, features/aarch64-fpu.c, features/aarch64-pauth.c, features/aarch64-sve.c, features/i386/32bit-avx.c, features/i386/32bit-avx512.c, features/i386/32bit-core.c, features/i386/32bit-linux.c, features/i386/32bit-mpx.c, features/i386/32bit-pkeys.c, features/i386/32bit-segments.c, features/i386/32bit-sse.c, features/i386/64bit-avx.c, features/i386/64bit-avx512.c, features/i386/64bit-core.c, features/i386/64bit-linux.c, features/i386/64bit-mpx.c, features/i386/64bit-pkeys.c, features/i386/64bit-segments.c, features/i386/64bit-sse.c, features/i386/x32-core.c, features/riscv/32bit-cpu.c, features/riscv/32bit-csr.c, features/riscv/32bit-fpu.c, features/riscv/64bit-cpu.c, features/riscv/64bit-csr.c, features/riscv/64bit-fpu.c, features/tic6x-c6xp.c, features/tic6x-core.c, features/tic6x-gp.c, filename-seen-cache.h, findcmd.c, findvar.c, fork-child.c, gcore.c, gdb_bfd.c, gdb_bfd.h, gdb_proc_service.h, gdb_regex.c, gdb_select.h, gdb_usleep.c, gdbarch-selftests.c, gdbthread.h, gdbtypes.h, gnu-nat.c, go32-nat.c, guile/guile.c, guile/scm-ports.c, guile/scm-safe-call.c, guile/scm-type.c, i386-fbsd-nat.c, i386-fbsd-tdep.c, i386-go32-tdep.c, i386-linux-nat.c, i386-linux-tdep.c, i386-tdep.c, i387-tdep.c, ia64-libunwind-tdep.c, ia64-linux-nat.c, inf-child.c, inf-ptrace.c, infcall.c, infcall.h, infcmd.c, inferior-iter.h, inferior.c, inferior.h, inflow.c, inflow.h, infrun.c, infrun.h, inline-frame.c, language.h, linespec.c, linux-fork.c, linux-nat.c, linux-tdep.c, linux-thread-db.c, location.c, machoread.c, macrotab.h, main.c, maint.c, maint.h, memattr.c, memrange.h, mi/mi-cmd-break.h, mi/mi-cmd-env.c, mi/mi-cmd-stack.c, mi/mi-cmd-var.c, mi/mi-interp.c, mi/mi-main.c, mi/mi-parse.h, minsyms.c, mips-linux-tdep.c, namespace.h, nat/aarch64-linux-hw-point.c, nat/aarch64-linux-hw-point.h, nat/aarch64-linux.c, nat/aarch64-sve-linux-ptrace.c, nat/amd64-linux-siginfo.c, nat/fork-inferior.c, nat/linux-btrace.c, nat/linux-btrace.h, nat/linux-namespaces.c, nat/linux-nat.h, nat/linux-osdata.c, nat/linux-personality.c, nat/linux-procfs.c, nat/linux-ptrace.c, nat/linux-ptrace.h, nat/linux-waitpid.c, nat/mips-linux-watch.c, nat/mips-linux-watch.h, nat/ppc-linux.c, nat/x86-dregs.c, nat/x86-dregs.h, nat/x86-linux-dregs.c, nat/x86-linux.c, nto-procfs.c, nto-tdep.c, objfile-flags.h, objfiles.c, objfiles.h, obsd-nat.c, observable.h, osdata.c, p-valprint.c, parse.c, parser-defs.h, ppc-linux-nat.c, printcmd.c, probe.c, proc-api.c, procfs.c, producer.c, progspace.h, psymtab.h, python/py-framefilter.c, python/py-inferior.c, python/py-ref.h, python/py-type.c, python/python.c, record-btrace.c, record-full.c, record.c, record.h, regcache-dump.c, regcache.c, regcache.h, remote-fileio.c, remote-fileio.h, remote-sim.c, remote.c, riscv-tdep.c, rs6000-aix-tdep.c, rust-exp.y, s12z-tdep.c, selftest-arch.c, ser-base.c, ser-event.c, ser-pipe.c, ser-tcp.c, ser-unix.c, skip.c, solib-aix.c, solib-target.c, solib.c, source-cache.c, source.c, source.h, sparc-nat.c, spu-linux-nat.c, stack.c, stap-probe.c, symfile-add-flags.h, symfile.c, symfile.h, symtab.c, symtab.h, target-descriptions.c, target-descriptions.h, target-memory.c, target.c, target.h, target/waitstatus.c, target/waitstatus.h, thread-iter.h, thread.c, tilegx-tdep.c, top.c, top.h, tracefile-tfile.c, tracefile.c, tracepoint.c, tracepoint.h, tui/tui-io.c, ui-file.c, ui-out.h, unittests/array-view-selftests.c, unittests/child-path-selftests.c, unittests/cli-utils-selftests.c, unittests/common-utils-selftests.c, unittests/copy_bitwise-selftests.c, unittests/environ-selftests.c, unittests/format_pieces-selftests.c, unittests/function-view-selftests.c, unittests/lookup_name_info-selftests.c, unittests/memory-map-selftests.c, unittests/memrange-selftests.c, unittests/mkdir-recursive-selftests.c, unittests/observable-selftests.c, unittests/offset-type-selftests.c, unittests/optional-selftests.c, unittests/parse-connection-spec-selftests.c, unittests/ptid-selftests.c, unittests/rsp-low-selftests.c, unittests/scoped_fd-selftests.c, unittests/scoped_mmap-selftests.c, unittests/scoped_restore-selftests.c, unittests/string_view-selftests.c, unittests/style-selftests.c, unittests/tracepoint-selftests.c, unittests/unpack-selftests.c, unittests/utils-selftests.c, unittests/xml-utils-selftests.c, utils.c, utils.h, valarith.c, valops.c, valprint.c, value.c, value.h, varobj.c, varobj.h, windows-nat.c, x86-linux-nat.c, xml-support.c, xml-support.h, xml-tdesc.h, xstormy16-tdep.c, xtensa-linux-nat.c, dwarf2read.h: Change common to gdbsupport. gdb/gdbserver/ChangeLog 2019-07-09 Tom Tromey <tom@tromey.com> * configure: Rebuild. * configure.ac: Change common to gdbsupport. * acinclude.m4: Change common to gdbsupport. * Makefile.in (SFILES, OBS, GDBREPLAY_OBS, IPA_OBJS) (version-generated.c, gdbsupport/%-ipa.o, gdbsupport/%.o): Change common to gdbsupport. * ax.c, event-loop.c, fork-child.c, gdb_proc_service.h, gdbreplay.c, gdbthread.h, hostio-errno.c, hostio.c, i387-fp.c, inferiors.c, inferiors.h, linux-aarch64-tdesc-selftest.c, linux-amd64-ipa.c, linux-i386-ipa.c, linux-low.c, linux-tic6x-low.c, linux-x86-low.c, linux-x86-tdesc-selftest.c, linux-x86-tdesc.c, lynx-i386-low.c, lynx-low.c, mem-break.h, nto-x86-low.c, regcache.c, regcache.h, remote-utils.c, server.c, server.h, spu-low.c, symbol.c, target.h, tdesc.c, tdesc.h, thread-db.c, tracepoint.c, win32-i386-low.c, win32-low.c: Change common to gdbsupport.
2019-05-06 04:29:24 +02:00
#include "gdbsupport/gdb_sys_time.h"
#include <unistd.h>
#if HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
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>
#if USE_WIN32API
#include <ws2tcpip.h>
#endif
#if __QNX__
#include <sys/iomgr.h>
#endif /* __QNX__ */
* acconfig.h: Remove. * configure.ac: Add a test for socklen_t. Use three-argument AC_DEFINE throughout. * config.in: Regenerated using autoheader 2.59. * configure: Regenerated. * gdbreplay.c (socklen_t): Provide a default. (remote_open): Use socklen_t. * remote-utils.c (socklen_t): Provide a default. (remote_open): Use socklen_t. (convert_int_to_ascii, convert_ascii_to_int, decode_M_packet): Use unsigned char. * i387-fp.c (struct i387_fsave, struct i387_fxsave): Use unsigned char for buffers. * linux-low.c (linux_read_memory, linux_write_memory) (linux_read_auxv): Likewise. * mem-break.c (breakpoint_data, set_breakpoint_data, check_mem_read) (check_mem_write): Likewise. * mem-break.h (set_breakpoint_data, check_mem_read, check_mem_write): Likewise. * regcache.c (struct inferior_rgcache_data, registers_to_string) (registers_from_string, register_data): Likewise. * server.c (handle_query, main): Likewise. * server.h (convert_ascii_to_int, convert_int_to_ascii) (decode_M_packet): Likewise. * target.c (read_inferior_memory, write_inferior_memory): Likewise. * target.h (struct target_ops): Update read_memory, write_memory, and read_auxv. (read_inferior_memory, write_inferior_memory): Update. * linux-low.h (struct linux_target_ops): Change type of breakpoint to unsigned char *. * linux-arm-low.c, linux-cris-low.c, linux-crisv32-low.c, linux-i386-low.c, linux-m32r-low.c, linux-m68k-low.c, linux-mips-low.c, linux-ppc-low.c, linux-ppc64-low.c, linux-s390-low.c, linux-sh-low.c: Update for changes in read_inferior_memory and the_low_target->breakpoint.
2005-06-13 03:59:22 +02:00
#ifndef HAVE_SOCKLEN_T
typedef int socklen_t;
#endif
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#ifndef IN_PROCESS_AGENT
#if USE_WIN32API
# define INVALID_DESCRIPTOR INVALID_SOCKET
#else
# define INVALID_DESCRIPTOR -1
#endif
/* Extra value for readchar_callback. */
enum {
/* The callback is currently not scheduled. */
NOT_SCHEDULED = -1
};
/* Status of the readchar callback.
Either NOT_SCHEDULED or the callback id. */
static int readchar_callback = NOT_SCHEDULED;
static int readchar (void);
static void reset_readchar (void);
static void reschedule (void);
/* A cache entry for a successfully looked-up symbol. */
struct sym_cache
{
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
char *name;
CORE_ADDR addr;
struct sym_cache *next;
};
static int remote_is_stdio = 0;
static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR;
static gdb_fildes_t listen_desc = INVALID_DESCRIPTOR;
#ifdef USE_WIN32API
gdb/ * arm-wince-tdep.c: New. * config/arm/wince.mt (DEPRECATED_TM_FILE): Use tm-arm.h. (MT_CFLAGS): Delete. (TM_CLIBS): Delete. (TDEPFILES): Add arm-wince-tdep.o, corelow.o, solib.o, solib-legacy.o, solib-svr4.o, and remove wince.o. * configure.tgt (arm*-*-mingw32ce*): Add. * signals/signals.c [HAVE_SIGNAL_H]: Check. (do_target_signal_to_host): Silence 'not used' warning. * config/arm/tm-wince.h: Remove. gdb/gdbserver/ * gdbserver/configure.ac: Add errno checking. (AC_CHECK_HEADERS): Add errno.h, fcntl.h, signal.h, sys/file.h and malloc.h. (AC_CHECK_DECLS): Add perror. (srv_mingwce): Handle. * gdbserver/configure.srv (i[34567]86-*-cygwin*): Add win32-i386-low.o to srv_tgtobj. (i[34567]86-*-mingw*): Likewise. (arm*-*-mingw32ce*): Add case. * gdbreplay.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_ERRNO_H, HAVE_MALLOC_H]: Check. [__MINGW32CE__] (strerror): New function. [__MINGW32CE__] (errno): Define to GetLastError. [__MINGW32CE__] (COUNTOF): New macro. (remote_open): Remove extra close call. * mem-break.c (delete_breakpoint_at): New function. * mem-break.h (delete_breakpoint_at): Declare. * remote-utils.c [HAVE_SYS_FILE_H, HAVE_SIGNAL_H, HAVE_FCNTL_H, HAVE_UNISTD_H, HAVE_ERRNO_H]: Check. [USE_WIN32API] (read, write): Add char* casts. * server.c [HAVE_UNISTD_H, HAVE_SIGNAL_H]: Check. * server.h: Include wincecompat.h on Windows CE. [HAVE_ERRNO_H]: Check. (perror): Declare if not declared. * utils.c: Add stdlib.h, errno.h and malloc.h includes. (perror_with_name): Remove errno declaration. * wincecompat.h: New. * wincecompat.c: New. * win32-low.h: New. * win32-arm-low.c: New. * win32-i386-low.c: New. (win32-low.c): Include mem-break.h and win32-low.h, and winnt.h. (OUTMSG2): Make it safe. (_T): New macro. (COUNTOF): New macro. (NUM_REGS): Get it from the low target. (CONTEXT_EXTENDED_REGISTERS, CONTEXT_FLOATING_POINT, CONTEXT_DEBUG_REGISTERS): Add fallbacks to 0. (thread_rec): Let low target handle debug registers. (child_add_thread): Likewise. (child_init_thread_list): Likewise. (continue_one_thread): Likewise. (regptr): New. (do_child_fetch_inferior_registers): Move to ... * win32-i386-low.c: ... here, and rename to ... (do_fetch_inferior_registers): ... this. * win32-low.c (child_fetch_inferior_registers): Go through the low target. (do_child_store_inferior_registers): Use regptr. (strwinerror): New function. (win32_create_inferior): Handle Windows CE. Use strwinerror instead of strerror on Windows error codes. Add program to the error output. Don't close the main thread handle on Windows CE. (win32_attach): Use coredll.dll on Windows CE. (win32_kill): Close current process and current thread handles. (win32_detach): Use coredll.dll on Windows CE. (win32_resume): Let low target handle debug registers, and step request. (handle_exception): Add/Remove initial breakpoint. Avoid non-existant WSTOPSIG on Windows CE. (win32_read_inferior_memory): Cast to remove warning. (win32_arch_string): Go through the low target. (initialize_low): Call set_breakpoint_data with the low target's breakpoint. * win32-low.c (dr, FLAG_TRACE_BIT, FCS_REGNUM, FOP_REGNUM, mappings): Move to ... * win32-i386-low.c: ... here. * win32-low.c (win32_thread_info): Move to ... * win32-low.h: ... here. * Makefile.in (SFILES): Add win32-low.c, win32-i386-low.c, win32-arm-low.c and wincecompat.c. (all:): Add $EXEEXT. (install-only:): Likewise. (gdbserver:): Likewise. (gdbreplay:): Likewise. * config.in: Regenerate. * configure: Regenerate.
2007-03-29 03:06:48 +02:00
# define read(fd, buf, len) recv (fd, (char *) buf, len, 0)
# define write(fd, buf, len) send (fd, (char *) buf, len, 0)
#endif
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
int
gdb_connected (void)
{
return remote_desc != INVALID_DESCRIPTOR;
}
/* Return true if the remote connection is over stdio. */
int
remote_connection_is_stdio (void)
{
return remote_is_stdio;
}
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
static void
enable_async_notification (int fd)
{
#if defined(F_SETFL) && defined (FASYNC)
int save_fcntl_flags;
save_fcntl_flags = fcntl (fd, F_GETFL, 0);
fcntl (fd, F_SETFL, save_fcntl_flags | FASYNC);
#if defined (F_SETOWN)
fcntl (fd, F_SETOWN, getpid ());
#endif
#endif
}
static int
handle_accept_event (int err, gdb_client_data client_data)
{
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
struct sockaddr_storage sockaddr;
socklen_t len = sizeof (sockaddr);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("handling possible accept event\n");
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
remote_desc = accept (listen_desc, (struct sockaddr *) &sockaddr, &len);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
if (remote_desc == -1)
perror_with_name ("Accept failed");
/* Enable TCP keep alive process. */
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
socklen_t tmp = 1;
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
setsockopt (remote_desc, SOL_SOCKET, SO_KEEPALIVE,
(char *) &tmp, sizeof (tmp));
/* Tell TCP not to delay small packets. This greatly speeds up
interactive response. */
tmp = 1;
setsockopt (remote_desc, IPPROTO_TCP, TCP_NODELAY,
(char *) &tmp, sizeof (tmp));
#ifndef USE_WIN32API
signal (SIGPIPE, SIG_IGN); /* If we don't do this, then gdbserver simply
exits when the remote side dies. */
#endif
if (run_once)
{
#ifndef USE_WIN32API
close (listen_desc); /* No longer need this */
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
#else
closesocket (listen_desc); /* No longer need this */
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
#endif
}
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
/* Even if !RUN_ONCE no longer notice new connections. Still keep the
descriptor open for add_file_handler to wait for a new connection. */
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
delete_file_handler (listen_desc);
/* Convert IP address to string. */
char orig_host[GDB_NI_MAX_ADDR], orig_port[GDB_NI_MAX_PORT];
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
int r = getnameinfo ((struct sockaddr *) &sockaddr, len,
orig_host, sizeof (orig_host),
orig_port, sizeof (orig_port),
NI_NUMERICHOST | NI_NUMERICSERV);
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
if (r != 0)
fprintf (stderr, _("Could not obtain remote address: %s\n"),
gai_strerror (r));
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
else
fprintf (stderr, _("Remote debugging from host %s, port %s\n"),
orig_host, orig_port);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
enable_async_notification (remote_desc);
/* Register the event loop handler. */
add_file_handler (remote_desc, handle_serial_event, NULL);
/* We have a new GDB connection now. If we were disconnected
tracing, there's a window where the target could report a stop
event to the event loop, and since we have a connection now, we'd
try to send vStopped notifications to GDB. But, don't do that
until GDB as selected all-stop/non-stop, and has queried the
threads' status ('?'). */
target_async (0);
return 0;
}
/* Prepare for a later connection to a remote debugger.
NAME is the filename used for communication. */
void
remote_prepare (const char *name)
{
client_state &cs = get_client_state ();
#ifdef USE_WIN32API
static int winsock_initialized;
#endif
socklen_t tmp;
remote_is_stdio = 0;
if (strcmp (name, STDIO_CONNECTION_NAME) == 0)
{
/* We need to record fact that we're using stdio sooner than the
call to remote_open so start_inferior knows the connection is
via stdio. */
remote_is_stdio = 1;
cs.transport_is_reliable = 1;
return;
}
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
struct addrinfo hint;
struct addrinfo *ainfo;
memset (&hint, 0, sizeof (hint));
/* Assume no prefix will be passed, therefore we should use
AF_UNSPEC. */
hint.ai_family = AF_UNSPEC;
hint.ai_socktype = SOCK_STREAM;
hint.ai_protocol = IPPROTO_TCP;
parsed_connection_spec parsed
= parse_connection_spec_without_prefix (name, &hint);
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
if (parsed.port_str.empty ())
{
cs.transport_is_reliable = 0;
return;
}
#ifdef USE_WIN32API
if (!winsock_initialized)
{
WSADATA wsad;
WSAStartup (MAKEWORD (1, 0), &wsad);
winsock_initialized = 1;
}
#endif
int r = getaddrinfo (parsed.host_str.c_str (), parsed.port_str.c_str (),
&hint, &ainfo);
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
if (r != 0)
error (_("%s: cannot resolve name: %s"), name, gai_strerror (r));
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
scoped_free_addrinfo freeaddrinfo (ainfo);
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
struct addrinfo *iter;
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
for (iter = ainfo; iter != NULL; iter = iter->ai_next)
{
listen_desc = gdb_socket_cloexec (iter->ai_family, iter->ai_socktype,
iter->ai_protocol);
if (listen_desc >= 0)
break;
}
if (iter == NULL)
perror_with_name ("Can't open socket");
/* Allow rapid reuse of this port. */
tmp = 1;
setsockopt (listen_desc, SOL_SOCKET, SO_REUSEADDR, (char *) &tmp,
sizeof (tmp));
switch (iter->ai_family)
{
case AF_INET:
((struct sockaddr_in *) iter->ai_addr)->sin_addr.s_addr = INADDR_ANY;
break;
case AF_INET6:
((struct sockaddr_in6 *) iter->ai_addr)->sin6_addr = in6addr_any;
break;
default:
internal_error (__FILE__, __LINE__,
_("Invalid 'ai_family' %d\n"), iter->ai_family);
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
}
if (bind (listen_desc, iter->ai_addr, iter->ai_addrlen) != 0)
perror_with_name ("Can't bind address");
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
if (listen (listen_desc, 1) != 0)
perror_with_name ("Can't listen on socket");
cs.transport_is_reliable = 1;
}
/* Open a connection to a remote debugger.
NAME is the filename used for communication. */
void
remote_open (const char *name)
{
const char *port_str;
port_str = strchr (name, ':');
#ifdef USE_WIN32API
if (port_str == NULL)
error ("Only HOST:PORT is supported on this platform.");
#endif
if (strcmp (name, STDIO_CONNECTION_NAME) == 0)
{
fprintf (stderr, "Remote debugging using stdio\n");
/* Use stdin as the handle of the connection.
We only select on reads, for example. */
remote_desc = fileno (stdin);
enable_async_notification (remote_desc);
/* Register the event loop handler. */
add_file_handler (remote_desc, handle_serial_event, NULL);
}
#ifndef USE_WIN32API
else if (port_str == NULL)
{
struct stat statbuf;
if (stat (name, &statbuf) == 0
&& (S_ISCHR (statbuf.st_mode) || S_ISFIFO (statbuf.st_mode)))
remote_desc = open (name, O_RDWR);
else
{
errno = EINVAL;
remote_desc = -1;
}
if (remote_desc < 0)
perror_with_name ("Could not open remote device");
Assume termios is available, remove support for termio and sgtty This commit garbage collects the termio and sgtty support. GDB's terminal handling code still has support for the old termio and sgtty interfaces in addition to termios. However, I think it's pretty safe to assume that for a long, long time, Unix-like systems provide termios. GNU/Linux, Solaris, Cygwin, AIX, DJGPP, macOS and the BSDs all have had termios.h for many years. Looking around the web, I found discussions about FreeBSD folks trying to get rid of old sgtty.h a decade ago: https://lists.freebsd.org/pipermail/freebsd-hackers/2007-March/019983.html So I think support for termio and sgtty in GDB is just dead code that is never compiled anywhere and is just getting in the way. For example, serial_noflush_set_tty_state and the raw<->cooked concerns mentioned in inflow.c only exist because of sgtty (see hardwire_noflush_set_tty_state). Regtested on GNU/Linux. Confirmed that I can still build Solaris, DJGPP and AIX GDB and that the resulting GDBs still include the termios.h-guarded code. Confirmed mingw-w64 GDB still builds and skips the termios.h-guarded code. gdb/ChangeLog: 2017-11-06 Pedro Alves <palves@redhat.com> * Makefile.in (SER_HARDWIRE): Update comment. (HFILES_NO_SRCDIR): Remove gdb_termios.h. * common/gdb_termios.h: Delete file. * common/job-control.c: Include termios.h and unistd.h instead of gdb_termios.h. (gdb_setpgid): Remove HAVE_TERMIOS || TIOCGPGRP preprocessor check. (have_job_control): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS. Remove sgtty code. * configure.ac: No longer check for termio.h and sgtty.h. * configure: Regenerate. * inflow.c: Include termios.h instead of gdb_termios.h. Replace PROCESS_GROUP_TYPE checks with HAVE_TERMIOS_H checks throughout. Replace PROCESS_GROUP_TYPE references with pid_t references throughout. (gdb_getpgrp): Delete. (set_initial_gdb_ttystate): Use tcgetpgrp instead of gdb_getpgrp. (child_terminal_inferior): Remove comment. Remove sgtty code. (child_terminal_ours_1): Use tcgetpgrp directly instead of gdb_getpgrp. Use serial_set_tty_state instead aof serial_noflush_set_tty_state. Remove sgtty code. * inflow.h: Include unistd.h instead of gdb_termios.h. Replace PROCESS_GROUP_TYPE check with HAVE_TERMIOS_H check. (inferior_process_group): Now returns pid_t. * ser-base.c (ser_base_noflush_set_tty_state): Delete. * ser-base.h (ser_base_noflush_set_tty_state): Delete. * ser-event.c (serial_event_ops): Update. * ser-go32.c (dos_noflush_set_tty_state): Delete. (dos_ops): Update. * ser-mingw.c (hardwire_ops, tty_ops, pipe_ops, tcp_ops): Update. * ser-pipe.c (pipe_ops): Update. * ser-tcp.c (tcp_ops): Update. * ser-unix.c: Include termios.h instead of gdb_termios.h. Remove HAVE_TERMIOS checks. [HAVE_TERMIO] (struct hardwire_ttystate): Delete. [HAVE_SGTTY] (struct hardwire_ttystate): Delete. (get_tty_state, set_tty_state): Drop termio and sgtty code, and assume termios. (hardwire_noflush_set_tty_state): Delete. (hardwire_print_tty_state, hardwire_drain_output) (hardwire_flush_output, hardwire_flush_input) (hardwire_send_break, hardwire_raw, hardwire_setbaudrate) (hardwire_setstopbits, hardwire_setparity): Drop termio and sgtty code, and assume termios. (hardwire_ops): Update. (_initialize_ser_hardwire): Remove HAVE_TERMIOS check. * serial.c (serial_noflush_set_tty_state): Delete. * serial.h (serial_noflush_set_tty_state): Delete. (serial_ops::noflush_set_tty_state): Delete. gdb/gdbserver/ChangeLog: 2017-11-06 Pedro Alves <palves@redhat.com> * configure.ac: No longer check for termio.h and sgtty.h. * configure: Regenerate. * remote-utils.c: Include termios.h instead of gdb_termios.h. (remote_open): Check HAVE_TERMIOS_H instead of HAVE_TERMIOS. Remove termio and sgtty code.
2017-11-06 16:36:46 +01:00
#if HAVE_TERMIOS_H
{
struct termios termios;
1999-07-07 22:19:36 +02:00
tcgetattr (remote_desc, &termios);
termios.c_iflag = 0;
termios.c_oflag = 0;
termios.c_lflag = 0;
1999-07-07 22:19:36 +02:00
termios.c_cflag &= ~(CSIZE | PARENB);
termios.c_cflag |= CLOCAL | CS8;
termios.c_cc[VMIN] = 1;
termios.c_cc[VTIME] = 0;
1999-07-07 22:19:36 +02:00
tcsetattr (remote_desc, TCSANOW, &termios);
}
#endif
fprintf (stderr, "Remote debugging using %s\n", name);
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
enable_async_notification (remote_desc);
/* Register the event loop handler. */
add_file_handler (remote_desc, handle_serial_event, NULL);
}
#endif /* USE_WIN32API */
else
{
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
char listen_port[GDB_NI_MAX_PORT];
struct sockaddr_storage sockaddr;
socklen_t len = sizeof (sockaddr);
if (getsockname (listen_desc, (struct sockaddr *) &sockaddr, &len) < 0)
perror_with_name ("Can't determine port");
Implement IPv6 support for GDB/gdbserver This patch implements IPv6 support for both GDB and gdbserver. Based on my research, it is the fourth attempt to do that since 2006. Since I used ideas from all of the previous patches, I also added their authors's names on the ChangeLogs as a way to recognize their efforts. For reference sake, you can find the previous attempts at: https://sourceware.org/ml/gdb-patches/2006-09/msg00192.html https://sourceware.org/ml/gdb-patches/2014-02/msg00248.html https://sourceware.org/ml/gdb-patches/2016-02/msg00226.html The basic idea behind the patch is to start using the new 'getaddrinfo'/'getnameinfo' calls, which are responsible for translating names and addresses in a protocol-independent way. This means that if we ever have a new version of the IP protocol, we won't need to change the code again (or, at least, won't have to change the majority of the code). The function 'getaddrinfo' returns a linked list of possible addresses to connect to. Dealing with multiple addresses proved to be a hard task with the current TCP auto-retry mechanism implemented on ser-tcp:net_open. For example, when gdbserver listened only on an IPv4 socket: $ ./gdbserver --once 127.0.0.1:1234 ./a.out and GDB was instructed to try to connect to both IPv6 and IPv4 sockets: $ ./gdb -ex 'target extended-remote localhost:1234' ./a.out the user would notice a somewhat big delay before GDB was able to connect to the IPv4 socket. This happened because GDB was trying to connect to the IPv6 socket first, and had to wait until the connection timed out before it tried to connect to the IPv4 socket. For that reason, I had to rewrite the main loop and implement a new method for handling multiple connections. After some discussion, Pedro and I agreed on the following algorithm: 1) For each entry returned by 'getaddrinfo', we try to open a socket and connect to it. 2.a) If we have a successful 'connect', we just use that connection. 2.b) If we don't have a successfull 'connect', but if we've got a ECONNREFUSED (meaning the the connection was refused), we keep track of this fact by using a flag. 2.c) If we don't have a successfull 'connect', but if we've got a EINPROGRESS (meaning that the connection is in progress), we perform a 'select' call on the socket until we have a result (either a successful connection, or an error on the socket). 3) If tcp_auto_retry is true, and we haven't gotten a successful connection, and at least one of our attempts failed with ECONNREFUSED, then we wait a little bit (i.e., call 'wait_for_connect'), check to see if there was a timeout/interruption (in which case we bail out), and then go back to (1). After multiple tests, I was able to connect without delay on the scenario described above, and was also able to connect in all other types of scenarios. I also implemented some hostname parsing functions (along with their corresponding unit tests) which are used to help GDB and gdbserver to parse hostname strings provided by the user. These new functions are living inside common/netstuff.[ch]. I've had to do that since IPv6 introduces a new URL scheme, which defines that square brackets can be used to enclose the host part and differentiate it from the port (e.g., "[::1]:1234" means "host ::1, port 1234"). I spent some time thinking about a reasonable way to interpret what the user wants, and I came up with the following: - If the user has provided a prefix that doesn't specify the protocol version (i.e., "tcp:" or "udp:"), or if the user has not provided any prefix, don't make any assumptions (i.e., assume AF_UNSPEC when dealing with 'getaddrinfo') *unless* the host starts with "[" (in which case, assume it's an IPv6 host). - If the user has provided a prefix that does specify the protocol version (i.e., "tcp4:", "tcp6:", "udp4:" or "udp6:"), then respect that. This method doesn't follow strictly what RFC 2732 proposes (that literal IPv6 addresses should be provided enclosed in "[" and "]") because IPv6 addresses still can be provided without square brackets in our case, but since we have prefixes to specify protocol versions I think this is not an issue. Another thing worth mentioning is the new 'GDB_TEST_SOCKETHOST' testcase parameter, which makes it possible to specify the hostname (without the port) to be used when testing GDB and gdbserver. For example, to run IPv6 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp6:[::1]' Or, to run IPv4 tests: $ make check-gdb RUNTESTFLAGS='GDB_TEST_SOCKETHOST=tcp4:127.0.0.1' This required a few changes on the gdbserver-base.exp, and also a minimal adjustment on gdb.server/run-without-local-binary.exp. Finally, I've implemented a new testcase, gdb.server/server-connect.exp, which is supposed to run on the native host and perform various "smoke tests" using different connection methods. This patch has been regression-tested on BuildBot and locally, and also built using a x86_64-w64-mingw32 GCC, and no problems were found. gdb/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> Pedro Alves <palves@redhat.com> * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add 'unittests/parse-connection-spec-selftests.c'. (COMMON_SFILES): Add 'common/netstuff.c'. (HFILES_NO_SRCDIR): Add 'common/netstuff.h'. * NEWS (Changes since GDB 8.2): Mention IPv6 support. * common/netstuff.c: New file. * common/netstuff.h: New file. * ser-tcp.c: Include 'netstuff.h' and 'wspiapi.h'. (wait_for_connect): Update comment. New parameter 'gdb::optional<int> sock' instead of 'struct serial *scb'. Use 'sock' directly instead of 'scb->fd'. (try_connect): New function, with code from 'net_open'. (net_open): Rewrite main loop to deal with multiple sockets/addresses. Handle IPv6-style hostnames; implement support for IPv6 connections. * unittests/parse-connection-spec-selftests.c: New file. gdb/gdbserver/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * Makefile.in (SFILES): Add '$(srcdir)/common/netstuff.c'. (OBS): Add 'common/netstuff.o'. (GDBREPLAY_OBS): Likewise. * gdbreplay.c: Include 'wspiapi.h' and 'netstuff.h'. (remote_open): Implement support for IPv6 connections. * remote-utils.c: Include 'netstuff.h', 'filestuff.h' and 'wspiapi.h'. (handle_accept_event): Accept connections from IPv6 sources. (remote_prepare): Handle IPv6-style hostnames; implement support for IPv6 connections. (remote_open): Implement support for printing connections from IPv6 sources. gdb/testsuite/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * README (Testsuite Parameters): Mention new 'GDB_TEST_SOCKETHOST' parameter. * boards/native-extended-gdbserver.exp: Do not set 'sockethost' by default. * boards/native-gdbserver.exp: Likewise. * gdb.server/run-without-local-binary.exp: Improve regexp used for detecting when a remote debugging connection succeeds. * gdb.server/server-connect.exp: New file. * lib/gdbserver-support.exp (gdbserver_default_get_comm_port): Do not prefix the port number with ":". (gdbserver_start): New global GDB_TEST_SOCKETHOST. Implement support for detecting and using it. Add '$debughost_gdbserver' to the list of arguments used to start gdbserver. Handle case when gdbserver cannot resolve a network name. gdb/doc/ChangeLog: 2018-07-11 Sergio Durigan Junior <sergiodj@redhat.com> Jan Kratochvil <jan.kratochvil@redhat.com> Paul Fertser <fercerpav@gmail.com> Tsutomu Seki <sekiriki@gmail.com> * gdb.texinfo (Remote Connection Commands): Add explanation about new IPv6 support. Add new connection prefixes.
2018-05-18 07:29:24 +02:00
int r = getnameinfo ((struct sockaddr *) &sockaddr, len,
NULL, 0,
listen_port, sizeof (listen_port),
NI_NUMERICSERV);
if (r != 0)
fprintf (stderr, _("Can't obtain port where we are listening: %s"),
gai_strerror (r));
else
fprintf (stderr, _("Listening on port %s\n"), listen_port);
fflush (stderr);
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
/* Register the event loop handler. */
add_file_handler (listen_desc, handle_accept_event, NULL);
}
}
void
2000-07-30 03:48:28 +02:00
remote_close (void)
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
delete_file_handler (remote_desc);
disable_async_io ();
#ifdef USE_WIN32API
closesocket (remote_desc);
#else
if (! remote_connection_is_stdio ())
close (remote_desc);
#endif
GDBserver disconnected tracing support. * linux-low.c (linux_remove_process): Delete. (add_lwp): Don't set last_resume_kind here. (linux_kill): Use `mourn'. (linux_detach): Use `thread_db_detach', and `mourn'. (linux_mourn): New. (linux_attach_lwp_1): Adjust comment. (linux_attach): last_resume_kind moved the thread_info; adjust. (status_pending_p_callback): Adjust. (linux_wait_for_event_1): Adjust. (count_events_callback, select_singlestep_lwp_callback) (select_event_lwp_callback, cancel_breakpoints_callback) (db_wants_lwp_stopped, linux_wait_1, need_step_over_p) (proceed_one_lwp): Adjust. (linux_async): Add debug output. (linux_thread_stopped): New. (linux_pause_all): New. (linux_target_ops): Install linux_mourn, linux_thread_stopped and linux_pause_all. * linux-low.h (struct lwp_info): Delete last_resume_kind field. (thread_db_free): Delete declaration. (thread_db_detach, thread_db_mourn): Declare. * thread-db.c (thread_db_init): Use thread_db_mourn. (thread_db_free): Delete, split in two. (disable_thread_event_reporting): New. (thread_db_detach): New. (thread_db_mourn): New. * server.h (struct thread_info) <last_resume_kind>: New field. <attached>: Add comment. <gdb_detached>: New field. (handler_func): Change return type to int. (handle_serial_event, handle_target_event): Ditto. (gdb_connected): Declare. (tracing): Delete. (disconnected_tracing): Declare. (stop_tracing): Declare. * server.c (handle_query) <qSupported>: Report support for disconnected tracing. (queue_stop_reply_callback): Account for running threads. (gdb_wants_thread_stopped): New. (gdb_wants_all_threads_stopped): New. (gdb_reattached_process): New. (handle_status): Clear the `gdb_detached' flag of all processes. In all-stop, stop all threads. (main): Be sure to leave tfind mode. Handle disconnected tracing. (process_serial_event): If the remote connection breaks, or if an exit was forced with "monitor exit", force an event loop exit. Handle disconnected tracing on detach. (handle_serial_event): Adjust. (handle_target_event): If GDB isn't connected, forward events back to the inferior, unless the last process exited, in which case, exit gdbserver. Adjust interface. * remote-utils.c (remote_open): Don't block in accept. Instead register an event loop source on the listen socket file descriptor. Refactor bits into ... (listen_desc): ... this new global. (gdb_connected): ... this new function. (enable_async_notification): ... this new function. (handle_accept_event): ... this new function. (remote_close): Clear remote_desc. * inferiors.c (add_thread): Set the new thread's last_resume_kind. * target.h (struct target_ops) <mourn, thread_stopped, pause_all>: New fields. (mourn_inferior): Define. (target_process_qsupported): Avoid the dangling else problem. (thread_stopped): Define. (pause_all): Define. (target_waitstatus_to_string): Declare. * target.c (target_waitstatus_to_string): New. * tracepoint.c (tracing): Make extern. (disconnected_tracing): New. (stop_tracing): Make extern. Handle tracing stops due to GDB disconnecting. (cmd_qtdisconnected): New. (cmd_qtstatus): Report disconnected tracing status in trace reply. (handle_tracepoint_general_set): Handle QTDisconnected. * event-loop.c (event_handler_func): Change return type to int. (process_event): Bail out if the event handler wants the event loop to stop. (handle_file_event): Ditto. (start_event_loop): Bail out if the event handler wants the event loop to stop. * nto-low.c (nto_target_ops): Adjust. * spu-low.c (spu_wait): Don't remove the process here. (spu_target_ops): Adjust. * win32-low.c (win32_wait): Don't remove the process here. (win32_target_ops): Adjust.
2010-04-11 18:33:56 +02:00
remote_desc = INVALID_DESCRIPTOR;
reset_readchar ();
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#endif
#ifndef IN_PROCESS_AGENT
void
decode_address (CORE_ADDR *addrp, const char *start, int len)
{
CORE_ADDR addr;
char ch;
int i;
addr = 0;
for (i = 0; i < len; i++)
{
ch = start[i];
addr = addr << 4;
addr = addr | (fromhex (ch) & 0x0f);
}
*addrp = addr;
}
const char *
decode_address_to_semicolon (CORE_ADDR *addrp, const char *start)
{
const char *end;
end = start;
while (*end != '\0' && *end != ';')
end++;
decode_address (addrp, start, end - start);
if (*end == ';')
end++;
return end;
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#endif
#ifndef IN_PROCESS_AGENT
/* Look for a sequence of characters which can be run-length encoded.
If there are any, update *CSUM and *P. Otherwise, output the
single character. Return the number of characters consumed. */
static int
try_rle (char *buf, int remaining, unsigned char *csum, char **p)
{
int n;
/* Always output the character. */
*csum += buf[0];
*(*p)++ = buf[0];
/* Don't go past '~'. */
if (remaining > 97)
remaining = 97;
for (n = 1; n < remaining; n++)
if (buf[n] != buf[0])
break;
/* N is the index of the first character not the same as buf[0].
buf[0] is counted twice, so by decrementing N, we get the number
of characters the RLE sequence will replace. */
n--;
if (n < 3)
return 1;
/* Skip the frame characters. The manual says to skip '+' and '-'
also, but there's no reason to. Unfortunately these two unusable
characters double the encoded length of a four byte zero
value. */
while (n + 29 == '$' || n + 29 == '#')
n--;
*csum += '*';
*(*p)++ = '*';
*csum += n + 29;
*(*p)++ = n + 29;
return n + 1;
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#endif
#ifndef IN_PROCESS_AGENT
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
/* Write a PTID to BUF. Returns BUF+CHARACTERS_WRITTEN. */
char *
write_ptid (char *buf, ptid_t ptid)
{
client_state &cs = get_client_state ();
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
int pid, tid;
if (cs.multi_process)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
pid = ptid.pid ();
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
if (pid < 0)
buf += sprintf (buf, "p-%x.", -pid);
else
buf += sprintf (buf, "p%x.", pid);
}
Remove ptid_get_lwp This removes ptid_get_lwp in favor of calling the ptid_t::lwp method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_lwp): Remove. * common/ptid.h (ptid_get_lwp): Don't declare. * aarch64-linux-nat.c: Update. * ada-tasks.c: Update. * aix-thread.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * corelow.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gnu-nat.c: Update. * i386-cygwin-tdep.c: Update. * i386-gnu-nat.c: Update. * i386-linux-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * mips-linux-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * obsd-nat.c: Update. * ppc-fbsd-nat.c: Update. * ppc-linux-nat.c: Update. * procfs.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * remote.c: Update. * s390-linux-nat.c: Update. * sol-thread.c: Update. * sol2-tdep.c: Update. * spu-linux-nat.c: Update. * x86-linux-nat.c: Update. * xtensa-linux-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * thread-db.c: Update.
2018-06-11 20:10:09 +02:00
tid = ptid.lwp ();
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
if (tid < 0)
buf += sprintf (buf, "-%x", -tid);
else
buf += sprintf (buf, "%x", tid);
return buf;
}
static ULONGEST
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
hex_or_minus_one (const char *buf, const char **obuf)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
ULONGEST ret;
if (startswith (buf, "-1"))
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
ret = (ULONGEST) -1;
buf += 2;
}
else
buf = unpack_varlen_hex (buf, &ret);
if (obuf)
*obuf = buf;
return ret;
}
/* Extract a PTID from BUF. If non-null, OBUF is set to the to one
passed the last parsed char. Returns null_ptid on error. */
ptid_t
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
read_ptid (const char *buf, const char **obuf)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
{
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 = buf;
const char *pp;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
ULONGEST pid = 0, tid = 0;
if (*p == 'p')
{
/* Multi-process ptid. */
pp = unpack_varlen_hex (p + 1, &pid);
if (*pp != '.')
error ("invalid remote ptid: %s\n", p);
p = pp + 1;
tid = hex_or_minus_one (p, &pp);
if (obuf)
*obuf = pp;
return ptid_t (pid, tid, 0);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
/* No multi-process. Just a tid. */
tid = hex_or_minus_one (p, &pp);
/* Since GDB is not sending a process id (multi-process extensions
are off), then there's only one process. Default to the first in
the list. */
pid = pid_of (get_first_process ());
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
if (obuf)
*obuf = pp;
return ptid_t (pid, tid, 0);
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
}
/* Write COUNT bytes in BUF to the client.
The result is the number of bytes written or -1 if error.
This may return less than COUNT. */
static int
write_prim (const void *buf, int count)
{
if (remote_connection_is_stdio ())
return write (fileno (stdout), buf, count);
else
return write (remote_desc, buf, count);
}
/* Read COUNT bytes from the client and store in BUF.
The result is the number of bytes read or -1 if error.
This may return less than COUNT. */
static int
read_prim (void *buf, int count)
{
if (remote_connection_is_stdio ())
return read (fileno (stdin), buf, count);
else
return read (remote_desc, buf, count);
}
/* Send a packet to the remote machine, with error checking.
The data of the packet is in BUF, and the length of the
packet is in CNT. Returns >= 0 on success, -1 otherwise. */
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
static int
putpkt_binary_1 (char *buf, int cnt, int is_notif)
{
client_state &cs = get_client_state ();
int i;
unsigned char csum = 0;
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
char *buf2;
char *p;
int cc;
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
buf2 = (char *) xmalloc (strlen ("$") + cnt + strlen ("#nn") + 1);
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
/* Copy the packet into buffer BUF2, encapsulating it
and giving it a checksum. */
p = buf2;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (is_notif)
*p++ = '%';
else
*p++ = '$';
for (i = 0; i < cnt;)
i += try_rle (buf + i, cnt - i, &csum, &p);
*p++ = '#';
*p++ = tohex ((csum >> 4) & 0xf);
*p++ = tohex (csum & 0xf);
*p = '\0';
/* Send it over and over until we get a positive ack. */
do
{
if (write_prim (buf2, p - buf2) != p - buf2)
{
perror ("putpkt(write)");
free (buf2);
return -1;
}
if (cs.noack_mode || is_notif)
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
{
/* Don't expect an ack then. */
if (remote_debug)
{
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
if (is_notif)
debug_printf ("putpkt (\"%s\"); [notif]\n", buf2);
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
else
debug_printf ("putpkt (\"%s\"); [noack mode]\n", buf2);
debug_flush ();
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
}
break;
}
if (remote_debug)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
debug_printf ("putpkt (\"%s\"); [looking for ack]\n", buf2);
debug_flush ();
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
cc = readchar ();
if (cc < 0)
{
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
free (buf2);
return -1;
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
if (remote_debug)
{
debug_printf ("[received '%c' (0x%x)]\n", cc, cc);
debug_flush ();
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
/* Check for an input interrupt while we're here. */
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
if (cc == '\003' && current_thread != NULL)
(*the_target->request_interrupt) ();
}
while (cc != '+');
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
free (buf2);
return 1; /* Success! */
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
int
putpkt_binary (char *buf, int cnt)
{
return putpkt_binary_1 (buf, cnt, 0);
}
/* Send a packet to the remote machine, with error checking. The data
of the packet is in BUF, and the packet should be a NUL-terminated
string. Returns >= 0 on success, -1 otherwise. */
int
putpkt (char *buf)
{
return putpkt_binary (buf, strlen (buf));
}
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
int
putpkt_notif (char *buf)
{
return putpkt_binary_1 (buf, strlen (buf), 1);
}
/* Come here when we get an input interrupt from the remote side. This
interrupt should only be active while we are waiting for the child to do
something. Thus this assumes readchar:bufcnt is 0.
About the only thing that should come through is a ^C, which
will cause us to request child interruption. */
static void
2002-02-14 Daniel Jacobowitz <drow@mvista.com> * gdbserver/Makefile.in: Add regformats directory to INCLUDE_CFLAGS, and remove unused $(INCLUDE_DIR). Add regcache.c to OBS. Add generated register protocol files to clean target. Update dependencies for new objects, obsolete old target code. * gdbserver/linux-low.c: Remove all platform-specific code to new files. Remove various dead code. Update to use regcache functionality. * gdbserver/remote-utils.c (fromhex): Add return statement to quiet warning. (putpkt): Dynamically allocate buf2 because PBUFSIZ is no longer constant. (input_interrupt): Add integer parameter to match prototype of a signal handler. (outreg): Use register_data (). (prepare_resume_reply): Use gdbserver_expedite_regs. * gdbserver/server.c (main): Dynamically allocate own_buf because PBUFSIZ is no longer constant. Use registers_to_string () and registers_from_string (). * gdbserver/server.h: No longer include "defs.h". Add prototypes for error (), fatal (), and warning (). Update definition of PBUFSIZ to use regcache functionality. Add include guard. * gdbserver/utils.c (fatal): Add missing ``const''. (warning): New function. * regformats/regdat.sh: Include "regcache.h" in generated files. Provide init_registers () function. * regformats/regdef.h: Add prototype for set_register_cache (). Add include guard. * gdbserver/linux-arm-low.c: New file. * gdbserver/linux-i386-low.c: New file. * gdbserver/linux-ia64-low.c: New file. * gdbserver/linux-m68k-low.c: New file. * gdbserver/linux-mips-low.c: New file. * gdbserver/linux-ppc-low.c: New file. * gdbserver/linux-sh-low.c: New file. * gdbserver/regcache.c: New file. * gdbserver/regcache.h: New file. * gdbserver/low-linux.c: Removed obsolete file.
2002-02-14 07:21:24 +01:00
input_interrupt (int unused)
{
fd_set readset;
struct timeval immediate = { 0, 0 };
/* Protect against spurious interrupts. This has been observed to
be a problem under NetBSD 1.4 and 1.5. */
FD_ZERO (&readset);
FD_SET (remote_desc, &readset);
if (select (remote_desc + 1, &readset, 0, 0, &immediate) > 0)
{
int cc;
char c = 0;
cc = read_prim (&c, 1);
if (cc == 0)
{
fprintf (stderr, "client connection closed\n");
return;
}
gdbserver: don't pick a random thread if the current thread dies In all-stop mode, if the current thread disappears while stopping all threads, gdbserver calls set_desired_thread(0) ['0' means "I want the continue thread"] which just picks the first thread in the list. This looks like a dangerous thing to do. GDBserver continues processing whatever it was doing, but to the wrong thread. If debugging more than one process, we may even pick the wrong process. Instead, GDBserver should detect the situation and bail out of whatever is was doing. The backends used to pay attention to the set 'cont_thread' (the Hc thread, used in the old way to resume threads, before vCont), but all such 'cont_thread' checks have been eliminated meanwhile. The remaining implicit dependencies that I found on there being a selected thread in the backends are in the Ctrl-C handling, which some backends use as thread to send a signal to. Even that seems to me to be better handled by always using the first thread in the list or by using the signal_pid PID. In order to make this a systematic approach, I'm making set_desired_thread never fallback to a random thread, and instead end up with current_thread == NULL, like already done in non-stop mode. Then I updated all callers to handle the situation. I stumbled on this while fixing other bugs exposed by gdb.threads/fork-plus-threads.exp test. The problems I saw were fixed in a different way, but in any case, I think the potential for problems is more or less obvious, and the resulting code looks a bit less magical to me. Tested on x86-64 Fedora 20, w/ native-extended-gdbserver board. gdb/gdbserver/ChangeLog: 2015-08-21 Pedro Alves <palves@redhat.com> * linux-low.c (wait_for_sigstop): Always switch to no thread selected if the previously current thread dies. * lynx-low.c (lynx_request_interrupt): Use the first thread's process instead of the current thread's. * remote-utils.c (input_interrupt): Don't check if there's no current thread. * server.c (gdb_read_memory, gdb_write_memory): If setting the current thread to the general thread fails, error out. (handle_qxfer_auxv, handle_qxfer_libraries) (handle_qxfer_libraries_svr4, handle_qxfer_siginfo) (handle_qxfer_spu, handle_qxfer_statictrace, handle_qxfer_fdpic) (handle_query): Check if there's a thread selected instead of checking whether there's any thread in the thread list. (handle_qxfer_threads, handle_qxfer_btrace) (handle_qxfer_btrace_conf): Don't error out early if there's no thread in the thread list. (handle_v_cont, myresume): Don't set the current thread to the continue thread. (process_serial_event) <Hg handling>: Also set thread_id if the previous general thread is still alive. (process_serial_event) <g/G handling>: If setting the current thread to the general thread fails, error out. * spu-low.c (spu_resume, spu_request_interrupt): Use the first thread's lwp instead of the current thread's. * target.c (set_desired_thread): If the desired thread was not found, leave the current thread pointing to NULL. Return an int (boolean) indicating success. * target.h (set_desired_thread): Change return type to int.
2015-08-21 20:20:31 +02:00
else if (cc != 1 || c != '\003')
{
fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c);
if (isprint (c))
fprintf (stderr, "('%c')\n", c);
else
fprintf (stderr, "('\\x%02x')\n", c & 0xff);
return;
}
(*the_target->request_interrupt) ();
}
}
/* Check if the remote side sent us an interrupt request (^C). */
void
check_remote_input_interrupt_request (void)
{
/* This function may be called before establishing communications,
therefore we need to validate the remote descriptor. */
if (remote_desc == INVALID_DESCRIPTOR)
return;
input_interrupt (0);
}
/* Asynchronous I/O support. SIGIO must be unblocked when waiting,
in order to accept Control-C from the client, and must be blocked
when talking to the client. */
static void
block_unblock_async_io (int block)
{
#ifndef USE_WIN32API
sigset_t sigio_set;
sigemptyset (&sigio_set);
sigaddset (&sigio_set, SIGIO);
Add RAII class for blocking gdb signals This adds configury support and an RAII class that can be used to temporarily block signals that are used by gdb. (This class is not used in this patch, but it split out for easier review.) The idea of this patch is that these signals should only be delivered to the main thread. So, when creating a background thread, they are temporarily blocked; the blocked state is inherited by the new thread. The sigprocmask man page says: The use of sigprocmask() is unspecified in a multithreaded process; see pthread_sigmask(3). This patch changes gdb to use pthread_sigmask when appropriate, by introducing a convenience define. I've updated gdbserver as well, because I had to touch gdbsupport, and because the threading patches will make it link against the thread library. I chose not to touch the NTO code, because I don't know anything about that platform and because I cannot test it. Finally, this modifies an existing spot in the Guile layer to use the new facility. gdb/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * gdbsupport/signals-state-save-restore.c (original_signal_mask): Remove comment. (save_original_signals_state, restore_original_signals_state): Use gdb_sigmask. * linux-nat.c (block_child_signals, restore_child_signals_mask) (_initialize_linux_nat): Use gdb_sigmask. * guile/guile.c (_initialize_guile): Use block_signals. * Makefile.in (HFILES_NO_SRCDIR): Add gdb-sigmask.h. * gdbsupport/gdb-sigmask.h: New file. * event-top.c (async_sigtstp_handler): Use gdb_sigmask. * cp-support.c (gdb_demangle): Use gdb_sigmask. * gdbsupport/common.m4 (GDB_AC_COMMON): Check for pthread_sigmask. * configure, config.in: Rebuild. * gdbsupport/block-signals.h: New file. gdb/gdbserver/ChangeLog 2019-11-26 Tom Tromey <tom@tromey.com> * remote-utils.c (block_unblock_async_io): Use gdb_sigmask. * linux-low.c (linux_wait_for_event_filtered, linux_async): Use gdb_sigmask. * configure, config.in: Rebuild. Change-Id: If3f37dc57dd859c226e9e4d79458a0514746e8c6
2019-09-29 16:50:15 +02:00
gdb_sigmask (block ? SIG_BLOCK : SIG_UNBLOCK, &sigio_set, NULL);
#endif
}
#ifdef __QNX__
static void
nto_comctrl (int enable)
{
struct sigevent event;
if (enable)
{
event.sigev_notify = SIGEV_SIGNAL_THREAD;
event.sigev_signo = SIGIO;
event.sigev_code = 0;
event.sigev_value.sival_ptr = NULL;
event.sigev_priority = -1;
ionotify (remote_desc, _NOTIFY_ACTION_POLLARM, _NOTIFY_COND_INPUT,
&event);
}
else
ionotify (remote_desc, _NOTIFY_ACTION_POLL, _NOTIFY_COND_INPUT, NULL);
}
#endif /* __QNX__ */
/* Current state of asynchronous I/O. */
static int async_io_enabled;
/* Enable asynchronous I/O. */
void
2000-07-30 03:48:28 +02:00
enable_async_io (void)
{
if (async_io_enabled)
return;
block_unblock_async_io (0);
async_io_enabled = 1;
#ifdef __QNX__
nto_comctrl (1);
#endif /* __QNX__ */
}
/* Disable asynchronous I/O. */
void
2000-07-30 03:48:28 +02:00
disable_async_io (void)
{
if (!async_io_enabled)
return;
block_unblock_async_io (1);
async_io_enabled = 0;
#ifdef __QNX__
nto_comctrl (0);
#endif /* __QNX__ */
}
void
initialize_async_io (void)
{
/* Make sure that async I/O starts blocked. */
async_io_enabled = 1;
disable_async_io ();
/* Install the signal handler. */
#ifndef USE_WIN32API
signal (SIGIO, input_interrupt);
#endif
}
/* Internal buffer used by readchar.
These are global to readchar because reschedule_remote needs to be
able to tell whether the buffer is empty. */
static unsigned char readchar_buf[BUFSIZ];
static int readchar_bufcnt = 0;
static unsigned char *readchar_bufp;
/* Returns next char from remote GDB. -1 if error. */
static int
2000-07-30 03:48:28 +02:00
readchar (void)
{
int ch;
if (readchar_bufcnt == 0)
{
readchar_bufcnt = read_prim (readchar_buf, sizeof (readchar_buf));
if (readchar_bufcnt <= 0)
{
if (readchar_bufcnt == 0)
gdbserver: don't exit until GDB disconnects When testing with "target remote" with "maint set target-non-stop on", we regressions like this: Running /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/continue-pending-after-query.exp ... FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 6: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 10: continue until exit === gdb Summary === # of expected passes 28 # of unexpected failures 3 where gdb.log shows: continue Continuing. Remote communication error. Target disconnected.: Connection reset by peer. (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit Enabling gdb + gdbserver debug logs we see: gdbserver: <<<< exiting linux_wait_1 gdbserver: handling possible serial event gdbserver: Writing resume reply for LWP 11089.11089:0 gdbserver: handling possible serial event gdbserver: GDBserver exiting GDB: Packet received: OK GDB: infrun: prepare_to_wait GDB: Sending packet: $vStopped#55...Packet received: W0;process:2b51 GDB: Sending packet: $vStopped#55...Packet received: OK GDB: infrun: target_wait (-1.0.0, status) = GDB: infrun: -1.0.0 [Thread 0], GDB: infrun: status->kind = no-resumed GDB: Sending packet: $Hgp2b51.2b51#41...Remote connection closed (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 1: continue until exit Notice the "Packet received: W0;process:2b51" followed by vStopped->OK. That means the process exit notification was successfully sent to GDB and GDB fetched it. That makes gdbserver exit, in server.c:process_serial_event: if (!extended_protocol && have_ran && !target_running ()) { /* In non-stop, defer exiting until GDB had a chance to query the whole vStopped list (until it gets an OK). */ if (QUEUE_is_empty (notif_event_p, notif_stop.queue)) { /* Be transparent when GDB is connected through stdio -- no need to spam GDB's console. */ if (!remote_connection_is_stdio ()) fprintf (stderr, "GDBserver exiting\n"); remote_close (); exit (0); } } However, GDB is still busy processing an earlier "no-resumed" event, and sends a "Hg" packet, which errors out with "Remote connection closed". IOW, it's not enough to wait for GDB to query the whole vStopped list, gdbserver needs to wait until the exit event is really processed. The fix is to make gdbserver not disconnect until gdb does. Tested on x86_64 Fedora, native gdbserver, remote + extended-remote + with and without "maint set target-non-stop on". gdb/gdbserver/ChangeLog: 2015-10-14 Pedro Alves <palves@redhat.com> * remote-utils.c (readchar): Don't print "Got EOF" unless debugging gdbserver. * server.c (captured_main): Exit gdbserver if gdb disconnects when in "target remote" mode and there are no processes left to debug. (process_serial_event): Remove 'have_ran' static local and remove logic that exits gdbserver in "target remote" mode.
2015-11-30 17:05:27 +01:00
{
if (remote_debug)
debug_printf ("readchar: Got EOF\n");
gdbserver: don't exit until GDB disconnects When testing with "target remote" with "maint set target-non-stop on", we regressions like this: Running /home/pedro/gdb/mygit/build/../src/gdb/testsuite/gdb.threads/continue-pending-after-query.exp ... FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 6: continue until exit FAIL: gdb.threads/continue-pending-after-query.exp: iter 10: continue until exit === gdb Summary === # of expected passes 28 # of unexpected failures 3 where gdb.log shows: continue Continuing. Remote communication error. Target disconnected.: Connection reset by peer. (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 4: continue until exit Enabling gdb + gdbserver debug logs we see: gdbserver: <<<< exiting linux_wait_1 gdbserver: handling possible serial event gdbserver: Writing resume reply for LWP 11089.11089:0 gdbserver: handling possible serial event gdbserver: GDBserver exiting GDB: Packet received: OK GDB: infrun: prepare_to_wait GDB: Sending packet: $vStopped#55...Packet received: W0;process:2b51 GDB: Sending packet: $vStopped#55...Packet received: OK GDB: infrun: target_wait (-1.0.0, status) = GDB: infrun: -1.0.0 [Thread 0], GDB: infrun: status->kind = no-resumed GDB: Sending packet: $Hgp2b51.2b51#41...Remote connection closed (gdb) FAIL: gdb.threads/continue-pending-after-query.exp: iter 1: continue until exit Notice the "Packet received: W0;process:2b51" followed by vStopped->OK. That means the process exit notification was successfully sent to GDB and GDB fetched it. That makes gdbserver exit, in server.c:process_serial_event: if (!extended_protocol && have_ran && !target_running ()) { /* In non-stop, defer exiting until GDB had a chance to query the whole vStopped list (until it gets an OK). */ if (QUEUE_is_empty (notif_event_p, notif_stop.queue)) { /* Be transparent when GDB is connected through stdio -- no need to spam GDB's console. */ if (!remote_connection_is_stdio ()) fprintf (stderr, "GDBserver exiting\n"); remote_close (); exit (0); } } However, GDB is still busy processing an earlier "no-resumed" event, and sends a "Hg" packet, which errors out with "Remote connection closed". IOW, it's not enough to wait for GDB to query the whole vStopped list, gdbserver needs to wait until the exit event is really processed. The fix is to make gdbserver not disconnect until gdb does. Tested on x86_64 Fedora, native gdbserver, remote + extended-remote + with and without "maint set target-non-stop on". gdb/gdbserver/ChangeLog: 2015-10-14 Pedro Alves <palves@redhat.com> * remote-utils.c (readchar): Don't print "Got EOF" unless debugging gdbserver. * server.c (captured_main): Exit gdbserver if gdb disconnects when in "target remote" mode and there are no processes left to debug. (process_serial_event): Remove 'have_ran' static local and remove logic that exits gdbserver in "target remote" mode.
2015-11-30 17:05:27 +01:00
}
else
perror ("readchar");
return -1;
}
readchar_bufp = readchar_buf;
}
readchar_bufcnt--;
ch = *readchar_bufp++;
reschedule ();
return ch;
}
/* Reset the readchar state machine. */
static void
reset_readchar (void)
{
readchar_bufcnt = 0;
if (readchar_callback != NOT_SCHEDULED)
{
delete_callback_event (readchar_callback);
readchar_callback = NOT_SCHEDULED;
}
}
/* Process remaining data in readchar_buf. */
static int
process_remaining (void *context)
{
int res;
/* This is a one-shot event. */
readchar_callback = NOT_SCHEDULED;
if (readchar_bufcnt > 0)
res = handle_serial_event (0, NULL);
else
res = 0;
return res;
}
/* If there is still data in the buffer, queue another event to process it,
we can't sleep in select yet. */
static void
reschedule (void)
{
if (readchar_bufcnt > 0 && readchar_callback == NOT_SCHEDULED)
readchar_callback = append_callback_event (process_remaining, NULL);
}
/* Read a packet from the remote machine, with error checking,
and store it in BUF. Returns length of packet, or negative if error. */
int
2000-07-30 03:48:28 +02:00
getpkt (char *buf)
{
client_state &cs = get_client_state ();
char *bp;
unsigned char csum, c1, c2;
int c;
while (1)
{
csum = 0;
while (1)
{
c = readchar ();
/* The '\003' may appear before or after each packet, so
check for an input interrupt. */
if (c == '\003')
{
(*the_target->request_interrupt) ();
continue;
}
if (c == '$')
break;
if (remote_debug)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
debug_printf ("[getpkt: discarding char '%c']\n", c);
debug_flush ();
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
if (c < 0)
return -1;
}
bp = buf;
while (1)
{
c = readchar ();
if (c < 0)
return -1;
if (c == '#')
break;
*bp++ = c;
csum += c;
}
*bp = 0;
c1 = fromhex (readchar ());
c2 = fromhex (readchar ());
1999-07-07 22:19:36 +02:00
if (csum == (c1 << 4) + c2)
break;
if (cs.noack_mode)
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
{
fprintf (stderr,
"Bad checksum, sentsum=0x%x, csum=0x%x, "
"buf=%s [no-ack-mode, Bad medium?]\n",
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
(c1 << 4) + c2, csum, buf);
/* Not much we can do, GDB wasn't expecting an ack/nac. */
break;
}
fprintf (stderr, "Bad checksum, sentsum=0x%x, csum=0x%x, buf=%s\n",
(c1 << 4) + c2, csum, buf);
if (write_prim ("-", 1) != 1)
return -1;
}
if (!cs.noack_mode)
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
{
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
if (remote_debug)
{
debug_printf ("getpkt (\"%s\"); [sending ack] \n", buf);
debug_flush ();
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
}
if (write_prim ("+", 1) != 1)
return -1;
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
if (remote_debug)
{
debug_printf ("[sent ack]\n");
debug_flush ();
gdb/doc/ 2008-08-12 Sandra Loosemore <sandra@codesourcery.com> * gdb.texinfo (Remote Configuration): Document set remote noack-packet. (Remote Protocol): Add Packet Acknowledgment to menu. (Overview): Mention +/- can be disabled, and point to new section where this is discussed in detail. (General Query Packets): Document QStartNoAckMode packet, and corresponding qSupported reply. (Packet Acknowledgment): New section. gdb/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> Add no-ack mode to the remote protocol --- optionally stop ACKing packets and responses when we have a reliable communication medium. Based on Apple's GDB, by Jason Molenda <jmolenda@apple.com> * remote.c (struct remote_state): Add noack_mode field. (PACKET_QStartNoAckMode): New. (remote_start_remote): Don't any outstanding packet here. (remote_open_1): Clear noack_mode. Ack any outstanding packet here. Activate noack mode if requested. (remote_protocol_features): Add QStartNoAckMode. (remote_open_1): (putpkt_binary): Don't send ack in noack mode. (read_frame): Don't recompute the checksum in noack mode. (getpkt_sane): Skip sending ack if in noack mode. (_initialize_remote): Add set/show remote noack mode. * NEWS: Note the new features. gdb/gdbserver/ 2008-08-12 Pedro Alves <pedro@codesourcery.com> * remote-utils.c (noack_mode, transport_is_reliable): New globals. (remote_open): Set or clear transport_is_reliable. (putpkt_binary): Don't expect acks in noack mode. (getpkt): Don't send ack/nac in noack mode. * server.c (handle_general_set): Handle QStartNoAckMode. (handle_query): If connected by tcp pass QStartNoAckMode+ in qSupported. (main): Reset noack_mode on every connection. * server.h (noack_mode): Declare.
2008-08-12 17:18:31 +02:00
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
}
else
{
if (remote_debug)
{
debug_printf ("getpkt (\"%s\"); [no ack sent] \n", buf);
debug_flush ();
}
}
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
[GDBserver] Check input interrupt after reading in a packet GDBserver may read some packet together with '\003' in one go. We've already checked '\003' first when reading packet by my patch, Check input interrupt first when reading packet https://sourceware.org/ml/gdb-patches/2016-01/msg00057.html but if we don't check '\003' *after* each packet, the interrupt will be processed next time GDBserver reads from the buffer, so that the interrupt isn't processed in time. For example, GDB sends vCont;c and interrupt (see gdb.base/interrupt-noterm.exp), we'll resume the inferior and wait once packet vCont;c is seen. If we don't check the interrupt character after vCont;c packet, interrupt character will stay in the buffer unattended until GDBserver returns from the wait, which may take a while. Note that since we've read '\003' from file descriptor, SIGIO signal handler input_interrupt doesn't help either. This issue can be exposed by hacking the end of getpkt like @@ -1041,6 +1050,9 @@ getpkt (char *buf) } } + if (readchar_bufcnt > 0) + gdb_assert (*readchar_bufp != '\003'); + return bp - buf; } and this can trigger internal error, (gdb) PASS: gdb.base/interrupt-noterm.exp: interrupt Remote connection closed^M (gdb) FAIL: gdb.base/interrupt-noterm.exp: inferior received SIGINT Remote debugging from host 10.2.206.40^M /home/yao/SourceCode/gnu/gdb/git/gdb/gdbserver/remote-utils.c:1054: A problem internal to GDBserver has been detected.^M getpkt: Assertion `*readchar_bufp != '\003'' failed.^M This patch is to peek the buffer, if it is '\003', consume it and call *the_target->request_interrupt. gdb/gdbserver: 2016-01-26 Yao Qi <yao.qi@linaro.org> * remote-utils.c (getpkt): If the buffer isn't empty, and the first character is '\003', call *the_target->request_interrupt.
2016-01-26 14:50:22 +01:00
/* The readchar above may have already read a '\003' out of the socket
and moved it to the local buffer. For example, when GDB sends
vCont;c immediately followed by interrupt (see
gdb.base/interrupt-noterm.exp). As soon as we see the vCont;c, we'll
resume the inferior and wait. Since we've already moved the '\003'
to the local buffer, SIGIO won't help. In that case, if we don't
check for interrupt after the vCont;c packet, the interrupt character
would stay in the buffer unattended until after the next (unrelated)
stop. */
while (readchar_bufcnt > 0 && *readchar_bufp == '\003')
{
/* Consume the interrupt character in the buffer. */
readchar ();
(*the_target->request_interrupt) ();
}
return bp - buf;
}
void
2000-07-30 03:48:28 +02:00
write_ok (char *buf)
{
buf[0] = 'O';
buf[1] = 'K';
buf[2] = '\0';
}
void
2000-07-30 03:48:28 +02:00
write_enn (char *buf)
{
/* Some day, we should define the meanings of the error codes... */
buf[0] = 'E';
buf[1] = '0';
buf[2] = '1';
buf[3] = '\0';
}
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#endif
#ifndef IN_PROCESS_AGENT
static char *
* regcache.h (struct thread_info): Forward declare. (struct regcache): New. (new_register_cache): Adjust prototype. (get_thread_regcache): Declare. (free_register_cache): Adjust prototype. (registers_to_string, registers_from_string): Ditto. (supply_register, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Ditto. * regcache.c (struct inferior_regcache_data): Delete. (get_regcache): Rename to ... (get_thread_regcache): ... this. Adjust. Switch inferior before fetching registers. (regcache_invalidate_one): Adjust. (regcache_invalidate): Fix prototype. (new_register_cache): Return the new register cache. (free_register_cache): Change prototype. (realloc_register_cache): Adjust. (registers_to_string): Change prototype to take a regcache. Adjust. (registers_from_string): Ditto. (register_data): Ditto. (supply_register): Ditto. (supply_register_by_name): Ditto. (collect_register): Ditto. (collect_register_as_string): Ditto. (collect_register_by_name): Ditto. * server.c (process_serial_event): Adjust. * linux-low.h (regset_fill_func, regset_store_func): Change prototype. (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): Change prototype. * linux-low.c (get_stop_pc): Adjust. (check_removed_breakpoint): Adjust. (linux_wait_for_event): Adjust. (linux_resume_one_lwp): Adjust. (fetch_register): Add regcache parameter. Adjust. (usr_store_inferior_registers): Ditto. (regsets_fetch_inferior_registers): Ditto. (regsets_store_inferior_registers): Ditto. (linux_fetch_registers, linux_store_registers): Ditto. * i387-fp.c (i387_cache_to_fsave): Change prototype to take a regcache. Adjust. (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change prototype to take a regcache. (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * remote-utils.c (convert_ascii_to_int, outreg) (prepare_resume_reply): Change prototype to take a regcache. Adjust. * target.h (struct target_ops) <fetch_registers, store_registers>: Change prototype to take a regcache. (fetch_inferior_registers, store_inferior_registers): Change prototype to take a regcache. Adjust. * proc-service.c (ps_lgetregs): Adjust. * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to take a regcache. Adjust. * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset, arm_get_pc, arm_set_pc): (arm_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-cris-low.c (cris_get_pc, cris_set_pc) (cris_cannot_fetch_register): (cris_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-crisv32-low.c (cris_get_pc, cris_set_pc, cris_reinsert_addr, cris_write_data_breakpoint): Change prototype to take a regcache. Adjust. (cris_breakpoint_at, cris_insert_point, cris_remove_point): Adjust. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to take a regcache. Adjust. * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, (m68k_set_pc): Change prototype to take a regcache. Adjust. * linux-mips-low.c (mips_get_pc): (mips_set_pc): Change prototype to take a regcache. Adjust. (mips_reinsert_addr): Adjust. (mips_collect_register): Change prototype to take a regcache. Adjust. (mips_supply_register): (mips_collect_register_32bit, mips_supply_register_32bit) (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) (mips_store_fpregset): Ditto. * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): Ditto. (parse_spufs_run): Adjust. (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to take a regcache. Adjust. * linux-s390-low.c (s390_collect_ptrace_register) (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) (s390_set_pc): Change prototype to take a regcache. Adjust. (s390_arch_setup): Adjust. * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) (sh_fill_gregset): Change prototype to take a regcache. Adjust. * linux-sparc-low.c (sparc_fill_gregset_to_stack) (sparc_fill_gregset, sparc_store_gregset_from_stack) (sparc_store_gregset, sparc_get_pc): Change prototype to take a regcache. Adjust. (sparc_breakpoint_at): Adjust. * linux-xtensa-low.c (xtensa_fill_gregset): (xtensa_store_gregset): (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) (xtensa_set_pc): Change prototype to take a regcache. Adjust. * nto-low.c (nto_fetch_registers, nto_store_registers): Change prototype to take a regcache. Adjust. * win32-arm-low.c (arm_fetch_inferior_register) (arm_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-i386-low.c (i386_fetch_inferior_register) (i386_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-low.c (child_fetch_inferior_registers) (child_store_inferior_registers): Change prototype to take a regcache. Adjust. (win32_wait): Adjust. (win32_fetch_inferior_registers): Change prototype to take a regcache. Adjust. (win32_store_inferior_registers): Adjust. * win32-low.h (struct win32_target_ops) <fetch_inferior_register, store_inferior_register>: Change prototype to take a regcache.
2010-01-20 23:55:38 +01:00
outreg (struct regcache *regcache, int regno, char *buf)
{
1999-11-02 05:44:47 +01:00
if ((regno >> 12) != 0)
*buf++ = tohex ((regno >> 12) & 0xf);
if ((regno >> 8) != 0)
*buf++ = tohex ((regno >> 8) & 0xf);
*buf++ = tohex ((regno >> 4) & 0xf);
*buf++ = tohex (regno & 0xf);
*buf++ = ':';
* regcache.h (struct thread_info): Forward declare. (struct regcache): New. (new_register_cache): Adjust prototype. (get_thread_regcache): Declare. (free_register_cache): Adjust prototype. (registers_to_string, registers_from_string): Ditto. (supply_register, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Ditto. * regcache.c (struct inferior_regcache_data): Delete. (get_regcache): Rename to ... (get_thread_regcache): ... this. Adjust. Switch inferior before fetching registers. (regcache_invalidate_one): Adjust. (regcache_invalidate): Fix prototype. (new_register_cache): Return the new register cache. (free_register_cache): Change prototype. (realloc_register_cache): Adjust. (registers_to_string): Change prototype to take a regcache. Adjust. (registers_from_string): Ditto. (register_data): Ditto. (supply_register): Ditto. (supply_register_by_name): Ditto. (collect_register): Ditto. (collect_register_as_string): Ditto. (collect_register_by_name): Ditto. * server.c (process_serial_event): Adjust. * linux-low.h (regset_fill_func, regset_store_func): Change prototype. (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): Change prototype. * linux-low.c (get_stop_pc): Adjust. (check_removed_breakpoint): Adjust. (linux_wait_for_event): Adjust. (linux_resume_one_lwp): Adjust. (fetch_register): Add regcache parameter. Adjust. (usr_store_inferior_registers): Ditto. (regsets_fetch_inferior_registers): Ditto. (regsets_store_inferior_registers): Ditto. (linux_fetch_registers, linux_store_registers): Ditto. * i387-fp.c (i387_cache_to_fsave): Change prototype to take a regcache. Adjust. (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change prototype to take a regcache. (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * remote-utils.c (convert_ascii_to_int, outreg) (prepare_resume_reply): Change prototype to take a regcache. Adjust. * target.h (struct target_ops) <fetch_registers, store_registers>: Change prototype to take a regcache. (fetch_inferior_registers, store_inferior_registers): Change prototype to take a regcache. Adjust. * proc-service.c (ps_lgetregs): Adjust. * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to take a regcache. Adjust. * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset, arm_get_pc, arm_set_pc): (arm_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-cris-low.c (cris_get_pc, cris_set_pc) (cris_cannot_fetch_register): (cris_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-crisv32-low.c (cris_get_pc, cris_set_pc, cris_reinsert_addr, cris_write_data_breakpoint): Change prototype to take a regcache. Adjust. (cris_breakpoint_at, cris_insert_point, cris_remove_point): Adjust. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to take a regcache. Adjust. * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, (m68k_set_pc): Change prototype to take a regcache. Adjust. * linux-mips-low.c (mips_get_pc): (mips_set_pc): Change prototype to take a regcache. Adjust. (mips_reinsert_addr): Adjust. (mips_collect_register): Change prototype to take a regcache. Adjust. (mips_supply_register): (mips_collect_register_32bit, mips_supply_register_32bit) (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) (mips_store_fpregset): Ditto. * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): Ditto. (parse_spufs_run): Adjust. (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to take a regcache. Adjust. * linux-s390-low.c (s390_collect_ptrace_register) (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) (s390_set_pc): Change prototype to take a regcache. Adjust. (s390_arch_setup): Adjust. * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) (sh_fill_gregset): Change prototype to take a regcache. Adjust. * linux-sparc-low.c (sparc_fill_gregset_to_stack) (sparc_fill_gregset, sparc_store_gregset_from_stack) (sparc_store_gregset, sparc_get_pc): Change prototype to take a regcache. Adjust. (sparc_breakpoint_at): Adjust. * linux-xtensa-low.c (xtensa_fill_gregset): (xtensa_store_gregset): (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) (xtensa_set_pc): Change prototype to take a regcache. Adjust. * nto-low.c (nto_fetch_registers, nto_store_registers): Change prototype to take a regcache. Adjust. * win32-arm-low.c (arm_fetch_inferior_register) (arm_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-i386-low.c (i386_fetch_inferior_register) (i386_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-low.c (child_fetch_inferior_registers) (child_store_inferior_registers): Change prototype to take a regcache. Adjust. (win32_wait): Adjust. (win32_fetch_inferior_registers): Change prototype to take a regcache. Adjust. (win32_store_inferior_registers): Adjust. * win32-low.h (struct win32_target_ops) <fetch_inferior_register, store_inferior_register>: Change prototype to take a regcache.
2010-01-20 23:55:38 +01:00
collect_register_as_string (regcache, regno, buf);
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
buf += 2 * register_size (regcache->tdesc, regno);
*buf++ = ';';
return buf;
}
void
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
prepare_resume_reply (char *buf, ptid_t ptid,
struct target_waitstatus *status)
{
client_state &cs = get_client_state ();
if (debug_threads)
New gdbserver option --debug-format=timestamp. * NEWS: Mention it. gdbserver/ * configure.ac (AC_CHECK_FUNCS): Add test for gettimeofday. * configure: Regenerate. * config.in: Regenerate. * Makefile.in (SFILES): Add debug.c. (OBS): Add debug.o. * debug.c: New file. * debug.h: New file. * linux-aarch64-low.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * linux-arm-low.c (*): Ditto. * linux-cris-low.c (*): Ditto. * linux-crisv32-low.c (*): Ditto. * linux-m32r-low.c (*): Ditto. * linux-sparc-low.c (*): Ditto. * linux-x86.c (*): Ditto. * linux-low.c (*): Ditto. (linux_wait_1): Add calls to debug_enter, debug_exit. (linux_wait): Remove redundant debugging printf. (stop_all_lwps): Add calls to debug_enter, debug_exit. (linux_resume, unstop_all_lwps): Ditto. * mem-break.c (*): Update all debugging printfs to use debug_printf instead of fprintf. * remote-utils.c (*): Ditto. * thread-db.c (*): Ditto. * server.c #include <ctype.h>, "gdb_vecs.h". (debug_threads): Moved to debug.c. (*): Update all debugging printfs to use debug_printf instead of fprintf. (start_inferior): Replace call to fflush with call to debug_flush. (monitor_show_help): Mention set debug-format. (parse_debug_format_options): New function. (handle_monitor_command): Handle "monitor set debug-format". (gdbserver_usage): Mention --debug-format. (main): Parse --debug-format. * server.h (debug_threads): Declaration moved to debug.h. #include "debug.h". * tracepoint.c (trace_debug_1) [!IN_PROCESS_AGENT]: Add version of trace_debug_1 that uses debug_printf. (tracepoint_look_up_symbols): Update all debugging printfs to use debug_printf instead of fprintf. doc/ * gdb.texinfo (Server): Mention --debug-format=all|none|timestamp. (gdbserver man): Ditto. testsuite/ * gdb.server/server-mon.exp: Add tests for "set debug-format".
2014-01-22 23:17:39 +01:00
debug_printf ("Writing resume reply for %s:%d\n",
target_pid_to_str (ptid), status->kind);
switch (status->kind)
{
case TARGET_WAITKIND_STOPPED:
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
case TARGET_WAITKIND_FORKED:
2015-05-12 18:52:45 +02:00
case TARGET_WAITKIND_VFORKED:
PR remote/18965: vforkdone stop reply should indicate parent PID The vforkdone stop reply misses indicating the thread ID of the vfork parent which the event relates to: @cindex vfork events, remote reply @item vfork The packet indicates that @code{vfork} was called, and @var{r} is the thread ID of the new child process. Refer to @ref{thread-id syntax} for the format of the @var{thread-id} field. This packet is only applicable to targets that support vfork events. @cindex vforkdone events, remote reply @item vforkdone The packet indicates that a child process created by a vfork has either called @code{exec} or terminated, so that the address spaces of the parent and child process are no longer shared. The @var{r} part is ignored. This packet is only applicable to targets that support vforkdone events. Unfortunately, this is not just a documentation issue. GDBserver is really not specifying the thread ID. I noticed because in non-stop mode, gdb complains: [Thread 6089.6089] #1 stopped. #0 0x0000003615a011f0 in ?? () 0x0000003615a011f0 in ?? () (gdb) set debug remote 1 (gdb) c Continuing. Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2; Sending packet: $vStopped#55...Packet received: OK Sending packet: $D;17ce#af...Packet received: OK Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK Notification received: Stop:T05vforkdone:; No process or thread specified in stop reply: T05vforkdone:; (gdb) This is not non-stop-mode-specific, however. Consider e.g., that in all-stop, you may be debugging more than one process at the same time. You continue, and both processes vfork. So when you next get a T05vforkdone, there's no way to tell which of the parent processes is done with the vfork. Tests will be added later. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-09-15 Pedro Alves <palves@redhat.com> PR remote/18965 * remote-utils.c (prepare_resume_reply): Merge TARGET_WAITKIND_VFORK_DONE switch case with the TARGET_WAITKIND_FORKED case. gdb/doc/ChangeLog: 2015-09-15 Pedro Alves <palves@redhat.com> PR remote/18965 * gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r' part indicates the thread ID of the parent process.
2015-09-15 18:32:45 +02:00
case TARGET_WAITKIND_VFORK_DONE:
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
case TARGET_WAITKIND_EXECD:
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
case TARGET_WAITKIND_THREAD_CREATED:
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
case TARGET_WAITKIND_SYSCALL_ENTRY:
case TARGET_WAITKIND_SYSCALL_RETURN:
{
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
struct thread_info *saved_thread;
const char **regp;
* regcache.h (struct thread_info): Forward declare. (struct regcache): New. (new_register_cache): Adjust prototype. (get_thread_regcache): Declare. (free_register_cache): Adjust prototype. (registers_to_string, registers_from_string): Ditto. (supply_register, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Ditto. * regcache.c (struct inferior_regcache_data): Delete. (get_regcache): Rename to ... (get_thread_regcache): ... this. Adjust. Switch inferior before fetching registers. (regcache_invalidate_one): Adjust. (regcache_invalidate): Fix prototype. (new_register_cache): Return the new register cache. (free_register_cache): Change prototype. (realloc_register_cache): Adjust. (registers_to_string): Change prototype to take a regcache. Adjust. (registers_from_string): Ditto. (register_data): Ditto. (supply_register): Ditto. (supply_register_by_name): Ditto. (collect_register): Ditto. (collect_register_as_string): Ditto. (collect_register_by_name): Ditto. * server.c (process_serial_event): Adjust. * linux-low.h (regset_fill_func, regset_store_func): Change prototype. (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): Change prototype. * linux-low.c (get_stop_pc): Adjust. (check_removed_breakpoint): Adjust. (linux_wait_for_event): Adjust. (linux_resume_one_lwp): Adjust. (fetch_register): Add regcache parameter. Adjust. (usr_store_inferior_registers): Ditto. (regsets_fetch_inferior_registers): Ditto. (regsets_store_inferior_registers): Ditto. (linux_fetch_registers, linux_store_registers): Ditto. * i387-fp.c (i387_cache_to_fsave): Change prototype to take a regcache. Adjust. (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change prototype to take a regcache. (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * remote-utils.c (convert_ascii_to_int, outreg) (prepare_resume_reply): Change prototype to take a regcache. Adjust. * target.h (struct target_ops) <fetch_registers, store_registers>: Change prototype to take a regcache. (fetch_inferior_registers, store_inferior_registers): Change prototype to take a regcache. Adjust. * proc-service.c (ps_lgetregs): Adjust. * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to take a regcache. Adjust. * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset, arm_get_pc, arm_set_pc): (arm_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-cris-low.c (cris_get_pc, cris_set_pc) (cris_cannot_fetch_register): (cris_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-crisv32-low.c (cris_get_pc, cris_set_pc, cris_reinsert_addr, cris_write_data_breakpoint): Change prototype to take a regcache. Adjust. (cris_breakpoint_at, cris_insert_point, cris_remove_point): Adjust. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to take a regcache. Adjust. * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, (m68k_set_pc): Change prototype to take a regcache. Adjust. * linux-mips-low.c (mips_get_pc): (mips_set_pc): Change prototype to take a regcache. Adjust. (mips_reinsert_addr): Adjust. (mips_collect_register): Change prototype to take a regcache. Adjust. (mips_supply_register): (mips_collect_register_32bit, mips_supply_register_32bit) (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) (mips_store_fpregset): Ditto. * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): Ditto. (parse_spufs_run): Adjust. (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to take a regcache. Adjust. * linux-s390-low.c (s390_collect_ptrace_register) (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) (s390_set_pc): Change prototype to take a regcache. Adjust. (s390_arch_setup): Adjust. * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) (sh_fill_gregset): Change prototype to take a regcache. Adjust. * linux-sparc-low.c (sparc_fill_gregset_to_stack) (sparc_fill_gregset, sparc_store_gregset_from_stack) (sparc_store_gregset, sparc_get_pc): Change prototype to take a regcache. Adjust. (sparc_breakpoint_at): Adjust. * linux-xtensa-low.c (xtensa_fill_gregset): (xtensa_store_gregset): (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) (xtensa_set_pc): Change prototype to take a regcache. Adjust. * nto-low.c (nto_fetch_registers, nto_store_registers): Change prototype to take a regcache. Adjust. * win32-arm-low.c (arm_fetch_inferior_register) (arm_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-i386-low.c (i386_fetch_inferior_register) (i386_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-low.c (child_fetch_inferior_registers) (child_store_inferior_registers): Change prototype to take a regcache. Adjust. (win32_wait): Adjust. (win32_fetch_inferior_registers): Change prototype to take a regcache. Adjust. (win32_store_inferior_registers): Adjust. * win32-low.h (struct win32_target_ops) <fetch_inferior_register, store_inferior_register>: Change prototype to take a regcache.
2010-01-20 23:55:38 +01:00
struct regcache *regcache;
if ((status->kind == TARGET_WAITKIND_FORKED && cs.report_fork_events)
|| (status->kind == TARGET_WAITKIND_VFORKED
&& cs.report_vfork_events))
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
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
2015-05-12 18:52:45 +02:00
const char *event = (status->kind == TARGET_WAITKIND_FORKED
? "fork" : "vfork");
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
2015-05-12 18:52:45 +02:00
sprintf (buf, "T%02x%s:", signal, event);
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
buf += strlen (buf);
buf = write_ptid (buf, status->value.related_pid);
strcat (buf, ";");
}
else if (status->kind == TARGET_WAITKIND_VFORK_DONE
&& cs.report_vfork_events)
PR remote/18965: vforkdone stop reply should indicate parent PID The vforkdone stop reply misses indicating the thread ID of the vfork parent which the event relates to: @cindex vfork events, remote reply @item vfork The packet indicates that @code{vfork} was called, and @var{r} is the thread ID of the new child process. Refer to @ref{thread-id syntax} for the format of the @var{thread-id} field. This packet is only applicable to targets that support vfork events. @cindex vforkdone events, remote reply @item vforkdone The packet indicates that a child process created by a vfork has either called @code{exec} or terminated, so that the address spaces of the parent and child process are no longer shared. The @var{r} part is ignored. This packet is only applicable to targets that support vforkdone events. Unfortunately, this is not just a documentation issue. GDBserver is really not specifying the thread ID. I noticed because in non-stop mode, gdb complains: [Thread 6089.6089] #1 stopped. #0 0x0000003615a011f0 in ?? () 0x0000003615a011f0 in ?? () (gdb) set debug remote 1 (gdb) c Continuing. Sending packet: $QPassSignals:e;10;14;17;1a;1b;1c;21;24;25;2c;4c;#5f...Packet received: OK Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK Notification received: Stop:T05vfork:p17ce.17ce;06:40d7ffffff7f0000;07:30d7ffffff7f0000;10:e4c9eb1536000000;thread:p17c9.17c9;core:2; Sending packet: $vStopped#55...Packet received: OK Sending packet: $D;17ce#af...Packet received: OK Sending packet: $vCont;c:p17c9.17c9#88...Packet received: OK Notification received: Stop:T05vforkdone:; No process or thread specified in stop reply: T05vforkdone:; (gdb) This is not non-stop-mode-specific, however. Consider e.g., that in all-stop, you may be debugging more than one process at the same time. You continue, and both processes vfork. So when you next get a T05vforkdone, there's no way to tell which of the parent processes is done with the vfork. Tests will be added later. Tested on x86_64 Fedora 20. gdb/ChangeLog: 2015-09-15 Pedro Alves <palves@redhat.com> PR remote/18965 * remote-utils.c (prepare_resume_reply): Merge TARGET_WAITKIND_VFORK_DONE switch case with the TARGET_WAITKIND_FORKED case. gdb/doc/ChangeLog: 2015-09-15 Pedro Alves <palves@redhat.com> PR remote/18965 * gdb.texinfo (Stop Reply Packets): Explain that vforkdone's 'r' part indicates the thread ID of the parent process.
2015-09-15 18:32:45 +02:00
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
sprintf (buf, "T%02xvforkdone:;", signal);
}
else if (status->kind == TARGET_WAITKIND_EXECD && cs.report_exec_events)
Extended-remote follow-exec This patch implements support for exec events on extended-remote Linux targets. Follow-exec-mode and rerun behave as expected. Catchpoints and test updates are implemented in subsequent patches. This patch was derived from a patch posted last October: https://sourceware.org/ml/gdb-patches/2014-10/msg00877.html. It was originally based on some work done by Luis Machado in 2013. IMPLEMENTATION ---------------- Exec events are enabled via ptrace options. When an exec event is detected by gdbserver, the existing process data, along with all its associated lwp and thread data, is deleted and replaced by data for a new single-threaded process. The new process data is initialized with the appropriate parts of the state of the execing process. This approach takes care of several potential pitfalls, including: * deleting the data for an execing non-leader thread before any wait/sigsuspend occurs * correctly initializing the architecture of the execed process We then report the exec event using a new RSP stop reason, "exec". When GDB receives an "exec" event, it saves the status in the event structure's target_waitstatus field, like what is done for remote fork events. Because the original and execed programs may have different architectures, we skip parsing the section of the stop reply packet that contains register data. The register data will be retrieved later after the inferior's architecture has been set up by infrun.c:follow_exec. At that point the exec event is handled by the existing event handling in GDB. However, a few changes were necessary so that infrun.c:follow_exec could accommodate the remote target. * Where follow-exec-mode "new" is handled, we now call add_inferior_with_spaces instead of add_inferior with separate calls to set up the program and address spaces. The motivation for this is that add_inferior_with_spaces also sets up the initial architecture for the inferior, which is needed later by target_find_description when it calls target_gdbarch. * We call a new target function, target_follow_exec. This function allows us to store the execd_pathname in the inferior, instead of using the static string remote_exec_file from remote.c. The static string didn't work for follow-exec-mode "new", since once you switched to the execed program, the original remote exec-file was lost. The execd_pathname is now stored in the inferior's program space as a REGISTRY field. All of the requisite mechanisms for this are defined in remote.c. gdb/gdbserver/ChangeLog: * linux-low.c (linux_mourn): Static declaration. (linux_arch_setup): Move in front of handle_extended_wait. (linux_arch_setup_thread): New function. (handle_extended_wait): Handle exec events. Call linux_arch_setup_thread. Make event_lwp argument a pointer-to-a-pointer. (check_zombie_leaders): Do not check stopped threads. (linux_low_ptrace_options): Add PTRACE_O_TRACEEXEC. (linux_low_filter_event): Add lwp and thread for exec'ing non-leader thread if leader thread has been deleted. Refactor code into linux_arch_setup_thread and call it. Pass child lwp pointer by reference to handle_extended_wait. (linux_wait_for_event_filtered): Update comment. (linux_wait_1): Prevent clobbering exec event status. (linux_supports_exec_events): New function. (linux_target_ops) <supports_exec_events>: Initialize new member. * lynx-low.c (lynx_target_ops) <supports_exec_events>: Initialize new member. * remote-utils.c (prepare_resume_reply): New stop reason 'exec'. * server.c (report_exec_events): New global variable. (handle_query): Handle qSupported query for exec-events feature. (captured_main): Initialize report_exec_events. * server.h (report_exec_events): Declare new global variable. * target.h (struct target_ops) <supports_exec_events>: New member. (target_supports_exec_events): New macro. * win32-low.c (win32_target_ops) <supports_exec_events>: Initialize new member. gdb/ChangeLog: * infrun.c (follow_exec): Use process-style ptid for exec message. Call add_inferior_with_spaces and target_follow_exec. * nat/linux-ptrace.c (linux_supports_traceexec): New function. * nat/linux-ptrace.h (linux_supports_traceexec): Declare. * remote.c (remote_pspace_data): New static variable. (remote_pspace_data_cleanup): New function. (get_remote_exec_file): New function. (set_remote_exec_file_1): New function. (set_remote_exec_file): New function. (show_remote_exec_file): New function. (remote_exec_file): Delete static variable. (anonymous enum) <PACKET_exec_event_feature> New enumeration constant. (remote_protocol_features): Add entry for exec-events feature. (remote_query_supported): Add client side of qSupported query for exec-events feature. (remote_follow_exec): New function. (remote_parse_stop_reply): Handle 'exec' stop reason. (extended_remote_run, extended_remote_create_inferior): Call get_remote_exec_file and set_remote_exec_file_1. (init_extended_remote_ops) <to_follow_exec>: Initialize new member. (_initialize_remote): Call register_program_space_data_with_cleanup. Call add_packet_config_cmd for remote exec-events feature. Modify call to add_setshow_string_noescape_cmd for exec-file to use new functions set_remote_exec_file and show_remote_exec_file. * target-debug.h, target-delegates.c: Regenerated. * target.c (target_follow_exec): New function. * target.h (struct target_ops) <to_follow_exec>: New member. (target_follow_exec): Declare new function.
2015-09-11 20:06:02 +02:00
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
const char *event = "exec";
char hexified_pathname[PATH_MAX * 2];
sprintf (buf, "T%02x%s:", signal, event);
buf += strlen (buf);
/* Encode pathname to hexified format. */
bin2hex ((const gdb_byte *) status->value.execd_pathname,
hexified_pathname,
strlen (status->value.execd_pathname));
sprintf (buf, "%s;", hexified_pathname);
xfree (status->value.execd_pathname);
status->value.execd_pathname = NULL;
buf += strlen (buf);
}
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
else if (status->kind == TARGET_WAITKIND_THREAD_CREATED
&& cs.report_thread_events)
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
sprintf (buf, "T%02xcreate:;", signal);
}
Implement 'catch syscall' for gdbserver This adds a new QCatchSyscalls packet to enable 'catch syscall', and new stop reasons "syscall_entry" and "syscall_return" for those events. It is currently only supported on Linux x86 and x86_64. gdb/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * NEWS (Changes since GDB 7.10): Mention QCatchSyscalls and the syscall_entry and syscall_return stop reasons. Mention GDB support for remote catch syscall. * remote.c (PACKET_QCatchSyscalls): New enum. (remote_set_syscall_catchpoint): New function. (remote_protocol_features): New element for QCatchSyscalls. (remote_parse_stop_reply): Parse syscall_entry/return stops. (init_remote_ops): Install remote_set_syscall_catchpoint. (_initialize_remote): Config QCatchSyscalls. * linux-nat.h (struct lwp_info) <syscall_state>: Comment typo. gdb/doc/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.texinfo (Remote Configuration): List the QCatchSyscalls packet. (Stop Reply Packets): List the syscall entry and return stop reasons. (General Query Packets): Describe QCatchSyscalls, and add it to the table and the detailed list of stub features. gdb/gdbserver/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * inferiors.h: Include "gdb_vecs.h". (struct process_info): Add syscalls_to_catch. * inferiors.c (remove_process): Free syscalls_to_catch. * remote-utils.c (prepare_resume_reply): Report syscall_entry and syscall_return stops. * server.h (UNKNOWN_SYSCALL, ANY_SYSCALL): Define. * server.c (handle_general_set): Handle QCatchSyscalls. (handle_query): Report support for QCatchSyscalls. * target.h (struct target_ops): Add supports_catch_syscall. (target_supports_catch_syscall): New macro. * linux-low.h (struct linux_target_ops): Add get_syscall_trapinfo. (struct lwp_info): Add syscall_state. * linux-low.c (handle_extended_wait): Mark syscall_state as an entry. Maintain syscall_state and syscalls_to_catch across exec. (get_syscall_trapinfo): New function, proxy to the_low_target. (linux_low_ptrace_options): Enable PTRACE_O_TRACESYSGOOD. (linux_low_filter_event): Toggle syscall_state entry/return for syscall traps, and set it ignored for all others. (gdb_catching_syscalls_p): New function. (gdb_catch_this_syscall_p): New function. (linux_wait_1): Handle SYSCALL_SIGTRAP. (linux_resume_one_lwp_throw): Add PTRACE_SYSCALL possibility. (linux_supports_catch_syscall): New function. (linux_target_ops): Install it. * linux-x86-low.c (x86_get_syscall_trapinfo): New function. (the_low_target): Install it. gdb/testsuite/ChangeLog: 2016-01-12 Josh Stone <jistone@redhat.com> Philippe Waroquiers <philippe.waroquiers@skynet.be> * gdb.base/catch-syscall.c (do_execve): New variable. (main): Conditionally trigger an execve. * gdb.base/catch-syscall.exp: Enable testing for remote targets. (test_catch_syscall_execve): New, check entry/return across execve. (do_syscall_tests): Call test_catch_syscall_execve.
2016-01-12 21:27:27 +01:00
else if (status->kind == TARGET_WAITKIND_SYSCALL_ENTRY
|| status->kind == TARGET_WAITKIND_SYSCALL_RETURN)
{
enum gdb_signal signal = GDB_SIGNAL_TRAP;
const char *event = (status->kind == TARGET_WAITKIND_SYSCALL_ENTRY
? "syscall_entry" : "syscall_return");
sprintf (buf, "T%02x%s:%x;", signal, event,
status->value.syscall_number);
}
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
else
sprintf (buf, "T%02x", status->value.sig);
buf += strlen (buf);
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
saved_thread = current_thread;
Multi-target support This commit adds multi-target support to GDB. What this means is that with this commit, GDB can now be connected to different targets at the same time. E.g., you can debug a live native process and a core dump at the same time, connect to multiple gdbservers, etc. Actually, the word "target" is overloaded in gdb. We already have a target stack, with pushes several target_ops instances on top of one another. We also have "info target" already, which means something completely different to what this patch does. So from here on, I'll be using the "target connections" term, to mean an open process_stratum target, pushed on a target stack. This patch makes gdb have multiple target stacks, and multiple process_stratum targets open simultaneously. The user-visible changes / commands will also use this terminology, but of course it's all open to debate. User-interface-wise, not that much changes. The main difference is that each inferior may have its own target connection. A target connection (e.g., a target extended-remote connection) may support debugging multiple processes, just as before. Say you're debugging against gdbserver in extended-remote mode, and you do "add-inferior" to prepare to spawn a new process, like: (gdb) target extended-remote :9999 ... (gdb) start ... (gdb) add-inferior Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) file a.out ... (gdb) start ... At this point, you have two inferiors connected to the same gdbserver. With this commit, GDB will maintain a target stack per inferior, instead of a global target stack. To preserve the behavior above, by default, "add-inferior" makes the new inferior inherit a copy of the target stack of the current inferior. Same across a fork - the child inherits a copy of the target stack of the parent. While the target stacks are copied, the targets themselves are not. Instead, target_ops is made a refcounted_object, which means that target_ops instances are refcounted, which each inferior counting for a reference. What if you want to create an inferior and connect it to some _other_ target? For that, this commit introduces a new "add-inferior -no-connection" option that makes the new inferior not share the current inferior's target. So you could do: (gdb) target extended-remote :9999 Remote debugging using :9999 ... (gdb) add-inferior -no-connection [New inferior 2] Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 <null> (gdb) tar extended-remote :10000 Remote debugging using :10000 ... (gdb) info inferiors Num Description Executable 1 process 18401 target:/home/pedro/tmp/main * 2 process 18450 target:/home/pedro/tmp/main (gdb) A following patch will extended "info inferiors" to include a column indicating which connection an inferior is bound to, along with a couple other UI tweaks. Other than that, debugging is the same as before. Users interact with inferiors and threads as before. The only difference is that inferiors may be bound to processes running in different machines. That's pretty much all there is to it in terms of noticeable UI changes. On to implementation. Since we can be connected to different systems at the same time, a ptid_t is no longer a unique identifier. Instead a thread can be identified by a pair of ptid_t and 'process_stratum_target *', the later being the instance of the process_stratum target that owns the process/thread. Note that process_stratum_target inherits from target_ops, and all process_stratum targets inherit from process_stratum_target. In earlier patches, many places in gdb were converted to refer to threads by thread_info pointer instead of ptid_t, but there are still places in gdb where we start with a pid/tid and need to find the corresponding inferior or thread_info objects. So you'll see in the patch many places adding a process_stratum_target parameter to functions that used to take only a ptid_t. Since each inferior has its own target stack now, we can always find the process_stratum target for an inferior. That is done via a inf->process_target() convenience method. Since each inferior has its own target stack, we need to handle the "beneath" calls when servicing target calls. The solution I settled with is just to make sure to switch the current inferior to the inferior you want before making a target call. Not relying on global context is just not feasible in current GDB. Fortunately, there aren't that many places that need to do that, because generally most code that calls target methods already has the current context pointing to the right inferior/thread. Note, to emphasize -- there's no method to "switch to this target stack". Instead, you switch the current inferior, and that implicitly switches the target stack. In some spots, we need to iterate over all inferiors so that we reach all target stacks. Native targets are still singletons. There's always only a single instance of such targets. Remote targets however, we'll have one instance per remote connection. The exec target is still a singleton. There's only one instance. I did not see the point of instanciating more than one exec_target object. After vfork, we need to make sure to push the exec target on the new inferior. See exec_on_vfork. For type safety, functions that need a {target, ptid} pair to identify a thread, take a process_stratum_target pointer for target parameter instead of target_ops *. Some shared code in gdb/nat/ also need to gain a target pointer parameter. This poses an issue, since gdbserver doesn't have process_stratum_target, only target_ops. To fix this, this commit renames gdbserver's target_ops to process_stratum_target. I think this makes sense. There's no concept of target stack in gdbserver, and gdbserver's target_ops really implements a process_stratum-like target. The thread and inferior iterator functions also gain process_stratum_target parameters. These are used to be able to iterate over threads and inferiors of a given target. Following usual conventions, if the target pointer is null, then we iterate over threads and inferiors of all targets. I tried converting "add-inferior" to the gdb::option framework, as a preparatory patch, but that stumbled on the fact that gdb::option does not support file options yet, for "add-inferior -exec". I have a WIP patchset that adds that, but it's not a trivial patch, mainly due to need to integrate readline's filename completion, so I deferred that to some other time. In infrun.c/infcmd.c, the main change is that we need to poll events out of all targets. See do_target_wait. Right after collecting an event, we switch the current inferior to an inferior bound to the target that reported the event, so that target methods can be used while handling the event. This makes most of the code transparent to multi-targets. See fetch_inferior_event. infrun.c:stop_all_threads is interesting -- in this function we need to stop all threads of all targets. What the function does is send an asynchronous stop request to all threads, and then synchronously waits for events, with target_wait, rinse repeat, until all it finds are stopped threads. Now that we have multiple targets, it's not efficient to synchronously block in target_wait waiting for events out of one target. Instead, we implement a mini event loop, with interruptible_select, select'ing on one file descriptor per target. For this to work, we need to be able to ask the target for a waitable file descriptor. Such file descriptors already exist, they are the descriptors registered in the main event loop with add_file_handler, inside the target_async implementations. This commit adds a new target_async_wait_fd target method that just returns the file descriptor in question. See wait_one / stop_all_threads in infrun.c. The 'threads_executing' global is made a per-target variable. Since it is only relevant to process_stratum_target targets, this is where it is put, instead of in target_ops. You'll notice that remote.c includes some FIXME notes. These refer to the fact that the global arrays that hold data for the remote packets supported are still globals. For example, if we connect to two different servers/stubs, then each might support different remote protocol features. They might even be different architectures, like e.g., one ARM baremetal stub, and a x86 gdbserver, to debug a host/controller scenario as a single program. That isn't going to work correctly today, because of said globals. I'm leaving fixing that for another pass, since it does not appear to be trivial, and I'd rather land the base work first. It's already useful to be able to debug multiple instances of the same server (e.g., a distributed cluster, where you have full control over the servers installed), so I think as is it's already reasonable incremental progress. Current limitations: - You can only resume more that one target at the same time if all targets support asynchronous debugging, and support non-stop mode. It should be possible to support mixed all-stop + non-stop backends, but that is left for another time. This means that currently in order to do multi-target with gdbserver you need to issue "maint set target-non-stop on". I would like to make that mode be the default, but we're not there yet. Note that I'm talking about how the target backend works, only. User-visible all-stop mode works just fine. - As explained above, connecting to different remote servers at the same time is likely to produce bad results if they don't support the exact set of RSP features. FreeBSD updates courtesy of John Baldwin. gdb/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> John Baldwin <jhb@FreeBSD.org> * aarch64-linux-nat.c (aarch64_linux_nat_target::thread_architecture): Adjust. * ada-tasks.c (print_ada_task_info): Adjust find_thread_ptid call. (task_command_1): Likewise. * aix-thread.c (sync_threadlists, aix_thread_target::resume) (aix_thread_target::wait, aix_thread_target::fetch_registers) (aix_thread_target::store_registers) (aix_thread_target::thread_alive): Adjust. * amd64-fbsd-tdep.c: Include "inferior.h". (amd64fbsd_get_thread_local_address): Pass down target. * amd64-linux-nat.c (ps_get_thread_area): Use ps_prochandle thread's gdbarch instead of target_gdbarch. * break-catch-sig.c (signal_catchpoint_print_it): Adjust call to get_last_target_status. * break-catch-syscall.c (print_it_catch_syscall): Likewise. * breakpoint.c (breakpoints_should_be_inserted_now): Consider all inferiors. (update_inserted_breakpoint_locations): Skip if inferiors with no execution. (update_global_location_list): When handling moribund locations, find representative inferior for location's pspace, and use thread count of its process_stratum target. * bsd-kvm.c (bsd_kvm_target_open): Pass target down. * bsd-uthread.c (bsd_uthread_target::wait): Use as_process_stratum_target and adjust thread_change_ptid and add_thread calls. (bsd_uthread_target::update_thread_list): Use as_process_stratum_target and adjust find_thread_ptid, thread_change_ptid and add_thread calls. * btrace.c (maint_btrace_packet_history_cmd): Adjust find_thread_ptid call. * corelow.c (add_to_thread_list): Adjust add_thread call. (core_target_open): Adjust add_thread_silent and thread_count calls. (core_target::pid_to_str): Adjust find_inferior_ptid call. * ctf.c (ctf_target_open): Adjust add_thread_silent call. * event-top.c (async_disconnect): Pop targets from all inferiors. * exec.c (add_target_sections): Push exec target on all inferiors sharing the program space. (remove_target_sections): Remove the exec target from all inferiors sharing the program space. (exec_on_vfork): New. * exec.h (exec_on_vfork): Declare. * fbsd-nat.c (fbsd_add_threads): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::update_thread_list): Adjust. (fbsd_nat_target::resume): Adjust. (fbsd_handle_debug_trap): Add fbsd_nat_target parameter. Pass it down. (fbsd_nat_target::wait, fbsd_nat_target::post_attach): Adjust. * fbsd-tdep.c (fbsd_corefile_thread): Adjust get_thread_arch_regcache call. * fork-child.c (gdb_startup_inferior): Pass target down to startup_inferior and set_executing. * gdbthread.h (struct process_stratum_target): Forward declare. (add_thread, add_thread_silent, add_thread_with_info) (in_thread_list): Add process_stratum_target parameter. (find_thread_ptid(inferior*, ptid_t)): New overload. (find_thread_ptid, thread_change_ptid): Add process_stratum_target parameter. (all_threads()): Delete overload. (all_threads, all_non_exited_threads): Add process_stratum_target parameter. (all_threads_safe): Use brace initialization. (thread_count): Add process_stratum_target parameter. (set_resumed, set_running, set_stop_requested, set_executing) (threads_are_executing, finish_thread_state): Add process_stratum_target parameter. (switch_to_thread): Use is_current_thread. * i386-fbsd-tdep.c: Include "inferior.h". (i386fbsd_get_thread_local_address): Pass down target. * i386-linux-nat.c (i386_linux_nat_target::low_resume): Adjust. * inf-child.c (inf_child_target::maybe_unpush_target): Remove have_inferiors check. * inf-ptrace.c (inf_ptrace_target::create_inferior) (inf_ptrace_target::attach): Adjust. * infcall.c (run_inferior_call): Adjust. * infcmd.c (run_command_1): Pass target to scoped_finish_thread_state. (proceed_thread_callback): Skip inferiors with no execution. (continue_command): Rename 'all_threads' local to avoid hiding 'all_threads' function. Adjust get_last_target_status call. (prepare_one_step): Adjust set_running call. (signal_command): Use user_visible_resume_target. Compare thread pointers instead of inferior_ptid. (info_program_command): Adjust to pass down target. (attach_command): Mark target's 'thread_executing' flag. (stop_current_target_threads_ns): New, factored out from ... (interrupt_target_1): ... this. Switch inferior before making target calls. * inferior-iter.h (struct all_inferiors_iterator, struct all_inferiors_range) (struct all_inferiors_safe_range) (struct all_non_exited_inferiors_range): Filter on process_stratum_target too. Remove explicit. * inferior.c (inferior::inferior): Push dummy target on target stack. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors): Add process_stratum_target parameter, and pass it down. (have_live_inferiors): Adjust. (switch_to_inferior_and_push_target): New. (add_inferior_command, clone_inferior_command): Handle "-no-connection" parameter. Use switch_to_inferior_and_push_target. (_initialize_inferior): Mention "-no-connection" option in the help of "add-inferior" and "clone-inferior" commands. * inferior.h: Include "process-stratum-target.h". (interrupt_target_1): Use bool. (struct inferior) <push_target, unpush_target, target_is_pushed, find_target_beneath, top_target, process_target, target_at, m_stack>: New. (discard_all_inferiors): Delete. (find_inferior_pid, find_inferior_ptid, number_of_live_inferiors) (all_inferiors, all_non_exited_inferiors): Add process_stratum_target parameter. * infrun.c: Include "gdb_select.h" and <unordered_map>. (target_last_proc_target): New global. (follow_fork_inferior): Push target on new inferior. Pass target to add_thread_silent. Call exec_on_vfork. Handle target's reference count. (follow_fork): Adjust get_last_target_status call. Also consider target. (follow_exec): Push target on new inferior. (struct execution_control_state) <target>: New field. (user_visible_resume_target): New. (do_target_resume): Call target_async. (resume_1): Set target's threads_executing flag. Consider resume target. (commit_resume_all_targets): New. (proceed): Also consider resume target. Skip threads of inferiors with no execution. Commit resumtion in all targets. (start_remote): Pass current inferior to wait_for_inferior. (infrun_thread_stop_requested): Consider target as well. Pass thread_info pointer to clear_inline_frame_state instead of ptid. (infrun_thread_thread_exit): Consider target as well. (random_pending_event_thread): New inferior parameter. Use it. (do_target_wait): Rename to ... (do_target_wait_1): ... this. Add inferior parameter, and pass it down. (threads_are_resumed_pending_p, do_target_wait): New. (prepare_for_detach): Adjust calls. (wait_for_inferior): New inferior parameter. Handle it. Use do_target_wait_1 instead of do_target_wait. (fetch_inferior_event): Adjust. Switch to representative inferior. Pass target down. (set_last_target_status): Add process_stratum_target parameter. Save target in global. (get_last_target_status): Add process_stratum_target parameter and handle it. (nullify_last_target_wait_ptid): Clear 'target_last_proc_target'. (context_switch): Check inferior_ptid == null_ptid before calling inferior_thread(). (get_inferior_stop_soon): Pass down target. (wait_one): Rename to ... (poll_one_curr_target): ... this. (struct wait_one_event): New. (wait_one): New. (stop_all_threads): Adjust. (handle_no_resumed, handle_inferior_event): Adjust to consider the event's target. (switch_back_to_stepped_thread): Also consider target. (print_stop_event): Update. (normal_stop): Update. Also consider the resume target. * infrun.h (wait_for_inferior): Remove declaration. (user_visible_resume_target): New declaration. (get_last_target_status, set_last_target_status): New process_stratum_target parameter. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter, and use it. (clear_inline_frame_state (thread_info*)): New. * inline-frame.c (clear_inline_frame_state(ptid_t)): Add process_stratum_target parameter. (clear_inline_frame_state (thread_info*)): Declare. * linux-fork.c (delete_checkpoint_command): Pass target down to find_thread_ptid. (checkpoint_command): Adjust. * linux-nat.c (linux_nat_target::follow_fork): Switch to thread instead of just tweaking inferior_ptid. (linux_nat_switch_fork): Pass target down to thread_change_ptid. (exit_lwp): Pass target down to find_thread_ptid. (attach_proc_task_lwp_callback): Pass target down to add_thread/set_running/set_executing. (linux_nat_target::attach): Pass target down to thread_change_ptid. (get_detach_signal): Pass target down to find_thread_ptid. Consider last target status's target. (linux_resume_one_lwp_throw, resume_lwp) (linux_handle_syscall_trap, linux_handle_extended_wait, wait_lwp) (stop_wait_callback, save_stop_reason, linux_nat_filter_event) (linux_nat_wait_1, resume_stopped_resumed_lwps): Pass target down. (linux_nat_target::async_wait_fd): New. (linux_nat_stop_lwp, linux_nat_target::thread_address_space): Pass target down. * linux-nat.h (linux_nat_target::async_wait_fd): Declare. * linux-tdep.c (get_thread_arch_regcache): Pass target down. * linux-thread-db.c (struct thread_db_info::process_target): New field. (add_thread_db_info): Save target. (get_thread_db_info): New process_stratum_target parameter. Also match target. (delete_thread_db_info): New process_stratum_target parameter. Also match target. (thread_from_lwp): Adjust to pass down target. (thread_db_notice_clone): Pass down target. (check_thread_db_callback): Pass down target. (try_thread_db_load_1): Always push the thread_db target. (try_thread_db_load, record_thread): Pass target down. (thread_db_target::detach): Pass target down. Always unpush the thread_db target. (thread_db_target::wait, thread_db_target::mourn_inferior): Pass target down. Always unpush the thread_db target. (find_new_threads_callback, thread_db_find_new_threads_2) (thread_db_target::update_thread_list): Pass target down. (thread_db_target::pid_to_str): Pass current inferior down. (thread_db_target::get_thread_local_address): Pass target down. (thread_db_target::resume, maintenance_check_libthread_db): Pass target down. * nto-procfs.c (nto_procfs_target::update_thread_list): Adjust. * procfs.c (procfs_target::procfs_init_inferior): Declare. (proc_set_current_signal, do_attach, procfs_target::wait): Adjust. (procfs_init_inferior): Rename to ... (procfs_target::procfs_init_inferior): ... this and adjust. (procfs_target::create_inferior, procfs_notice_thread) (procfs_do_thread_registers): Adjust. * ppc-fbsd-tdep.c: Include "inferior.h". (ppcfbsd_get_thread_local_address): Pass down target. * proc-service.c (ps_xfer_memory): Switch current inferior and program space as well. (get_ps_regcache): Pass target down. * process-stratum-target.c (process_stratum_target::thread_address_space) (process_stratum_target::thread_architecture): Pass target down. * process-stratum-target.h (process_stratum_target::threads_executing): New field. (as_process_stratum_target): New. * ravenscar-thread.c (ravenscar_thread_target::update_inferior_ptid): Pass target down. (ravenscar_thread_target::wait, ravenscar_add_thread): Pass target down. * record-btrace.c (record_btrace_target::info_record): Adjust. (record_btrace_target::record_method) (record_btrace_target::record_is_replaying) (record_btrace_target::fetch_registers) (get_thread_current_frame_id, record_btrace_target::resume) (record_btrace_target::wait, record_btrace_target::stop): Pass target down. * record-full.c (record_full_wait_1): Switch to event thread. Pass target down. * regcache.c (regcache::regcache) (get_thread_arch_aspace_regcache, get_thread_arch_regcache): Add process_stratum_target parameter and handle it. (current_thread_target): New global. (get_thread_regcache): Add process_stratum_target parameter and handle it. Switch inferior before calling target method. (get_thread_regcache): Pass target down. (get_thread_regcache_for_ptid): Pass target down. (registers_changed_ptid): Add process_stratum_target parameter and handle it. (registers_changed_thread, registers_changed): Pass target down. (test_get_thread_arch_aspace_regcache): New. (current_regcache_test): Define a couple local test_target_ops instances and use them for testing. (readwrite_regcache): Pass process_stratum_target parameter. (cooked_read_test, cooked_write_test): Pass mock_target down. * regcache.h (get_thread_regcache, get_thread_arch_regcache) (get_thread_arch_aspace_regcache): Add process_stratum_target parameter. (regcache::target): New method. (regcache::regcache, regcache::get_thread_arch_aspace_regcache) (regcache::registers_changed_ptid): Add process_stratum_target parameter. (regcache::m_target): New field. (registers_changed_ptid): Add process_stratum_target parameter. * remote.c (remote_state::supports_vCont_probed): New field. (remote_target::async_wait_fd): New method. (remote_unpush_and_throw): Add remote_target parameter. (get_current_remote_target): Adjust. (remote_target::remote_add_inferior): Push target. (remote_target::remote_add_thread) (remote_target::remote_notice_new_inferior) (get_remote_thread_info): Pass target down. (remote_target::update_thread_list): Skip threads of inferiors bound to other targets. (remote_target::close): Don't discard inferiors. (remote_target::add_current_inferior_and_thread) (remote_target::process_initial_stop_replies) (remote_target::start_remote) (remote_target::remote_serial_quit_handler): Pass down target. (remote_target::remote_unpush_target): New remote_target parameter. Unpush the target from all inferiors. (remote_target::remote_unpush_and_throw): New remote_target parameter. Pass it down. (remote_target::open_1): Check whether the current inferior has execution instead of checking whether any inferior is live. Pass target down. (remote_target::remote_detach_1): Pass down target. Use remote_unpush_target. (extended_remote_target::attach): Pass down target. (remote_target::remote_vcont_probe): Set supports_vCont_probed. (remote_target::append_resumption): Pass down target. (remote_target::append_pending_thread_resumptions) (remote_target::remote_resume_with_hc, remote_target::resume) (remote_target::commit_resume): Pass down target. (remote_target::remote_stop_ns): Check supports_vCont_probed. (remote_target::interrupt_query) (remote_target::remove_new_fork_children) (remote_target::check_pending_events_prevent_wildcard_vcont) (remote_target::remote_parse_stop_reply) (remote_target::process_stop_reply): Pass down target. (first_remote_resumed_thread): New remote_target parameter. Pass it down. (remote_target::wait_as): Pass down target. (unpush_and_perror): New remote_target parameter. Pass it down. (remote_target::readchar, remote_target::remote_serial_write) (remote_target::getpkt_or_notif_sane_1) (remote_target::kill_new_fork_children, remote_target::kill): Pass down target. (remote_target::mourn_inferior): Pass down target. Use remote_unpush_target. (remote_target::core_of_thread) (remote_target::remote_btrace_maybe_reopen): Pass down target. (remote_target::pid_to_exec_file) (remote_target::thread_handle_to_thread_info): Pass down target. (remote_target::async_wait_fd): New. * riscv-fbsd-tdep.c: Include "inferior.h". (riscv_fbsd_get_thread_local_address): Pass down target. * sol2-tdep.c (sol2_core_pid_to_str): Pass down target. * sol-thread.c (sol_thread_target::wait, ps_lgetregs, ps_lsetregs) (ps_lgetfpregs, ps_lsetfpregs, sol_update_thread_list_callback): Adjust. * solib-spu.c (spu_skip_standalone_loader): Pass down target. * solib-svr4.c (enable_break): Pass down target. * spu-multiarch.c (parse_spufs_run): Pass down target. * spu-tdep.c (spu2ppu_sniffer): Pass down target. * target-delegates.c: Regenerate. * target.c (g_target_stack): Delete. (current_top_target): Return the current inferior's top target. (target_has_execution_1): Refer to the passed-in inferior's top target. (target_supports_terminal_ours): Check whether the initial inferior was already created. (decref_target): New. (target_stack::push): Incref/decref the target. (push_target, push_target, unpush_target): Adjust. (target_stack::unpush): Defref target. (target_is_pushed): Return bool. Adjust to refer to the current inferior's target stack. (dispose_inferior): Delete, and inline parts ... (target_preopen): ... here. Only dispose of the current inferior. (target_detach): Hold strong target reference while detaching. Pass target down. (target_thread_name): Add assertion. (target_resume): Pass down target. (target_ops::beneath, find_target_at): Adjust to refer to the current inferior's target stack. (get_dummy_target): New. (target_pass_ctrlc): Pass the Ctrl-C to the first inferior that has a thread running. (initialize_targets): Rename to ... (_initialize_target): ... this. * target.h: Include "gdbsupport/refcounted-object.h". (struct target_ops): Inherit refcounted_object. (target_ops::shortname, target_ops::longname): Make const. (target_ops::async_wait_fd): New method. (decref_target): Declare. (struct target_ops_ref_policy): New. (target_ops_ref): New typedef. (get_dummy_target): Declare function. (target_is_pushed): Return bool. * thread-iter.c (all_matching_threads_iterator::m_inf_matches) (all_matching_threads_iterator::all_matching_threads_iterator): Handle filter target. * thread-iter.h (struct all_matching_threads_iterator, struct all_matching_threads_range, class all_non_exited_threads_range): Filter by target too. Remove explicit. * thread.c (threads_executing): Delete. (inferior_thread): Pass down current inferior. (clear_thread_inferior_resources): Pass down thread pointer instead of ptid_t. (add_thread_silent, add_thread_with_info, add_thread): Add process_stratum_target parameter. Use it for thread and inferior searches. (is_current_thread): New. (thread_info::deletable): Use it. (find_thread_ptid, thread_count, in_thread_list) (thread_change_ptid, set_resumed, set_running): New process_stratum_target parameter. Pass it down. (set_executing): New process_stratum_target parameter. Pass it down. Adjust reference to 'threads_executing'. (threads_are_executing): New process_stratum_target parameter. Adjust reference to 'threads_executing'. (set_stop_requested, finish_thread_state): New process_stratum_target parameter. Pass it down. (switch_to_thread): Also match inferior. (switch_to_thread): New process_stratum_target parameter. Pass it down. (update_threads_executing): Reimplement. * top.c (quit_force): Pop targets from all inferior. (gdb_init): Don't call initialize_targets. * windows-nat.c (windows_nat_target) <get_windows_debug_event>: Declare. (windows_add_thread, windows_delete_thread): Adjust. (get_windows_debug_event): Rename to ... (windows_nat_target::get_windows_debug_event): ... this. Adjust. * tracefile-tfile.c (tfile_target_open): Pass down target. * gdbsupport/common-gdbthread.h (struct process_stratum_target): Forward declare. (switch_to_thread): Add process_stratum_target parameter. * mi/mi-interp.c (mi_on_resume_1): Add process_stratum_target parameter. Use it. (mi_on_resume): Pass target down. * nat/fork-inferior.c (startup_inferior): Add process_stratum_target parameter. Pass it down. * nat/fork-inferior.h (startup_inferior): Add process_stratum_target parameter. * python/py-threadevent.c (py_get_event_thread): Pass target down. gdb/gdbserver/ChangeLog: 2020-01-10 Pedro Alves <palves@redhat.com> * fork-child.c (post_fork_inferior): Pass target down to startup_inferior. * inferiors.c (switch_to_thread): Add process_stratum_target parameter. * lynx-low.c (lynx_target_ops): Now a process_stratum_target. * nto-low.c (nto_target_ops): Now a process_stratum_target. * linux-low.c (linux_target_ops): Now a process_stratum_target. * remote-utils.c (prepare_resume_reply): Pass the target to switch_to_thread. * target.c (the_target): Now a process_stratum_target. (done_accessing_memory): Pass the target to switch_to_thread. (set_target_ops): Ajust to use process_stratum_target. * target.h (struct target_ops): Rename to ... (struct process_stratum_target): ... this. (the_target, set_target_ops): Adjust. (prepare_to_access_memory): Adjust comment. * win32-low.c (child_xfer_memory): Adjust to use process_stratum_target. (win32_target_ops): Now a process_stratum_target.
2020-01-10 21:06:08 +01:00
switch_to_thread (the_target, ptid);
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
regp = current_target_desc ()->expedite_regs;
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
regcache = get_thread_regcache (current_thread, 1);
* regcache.h (struct thread_info): Forward declare. (struct regcache): New. (new_register_cache): Adjust prototype. (get_thread_regcache): Declare. (free_register_cache): Adjust prototype. (registers_to_string, registers_from_string): Ditto. (supply_register, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Ditto. * regcache.c (struct inferior_regcache_data): Delete. (get_regcache): Rename to ... (get_thread_regcache): ... this. Adjust. Switch inferior before fetching registers. (regcache_invalidate_one): Adjust. (regcache_invalidate): Fix prototype. (new_register_cache): Return the new register cache. (free_register_cache): Change prototype. (realloc_register_cache): Adjust. (registers_to_string): Change prototype to take a regcache. Adjust. (registers_from_string): Ditto. (register_data): Ditto. (supply_register): Ditto. (supply_register_by_name): Ditto. (collect_register): Ditto. (collect_register_as_string): Ditto. (collect_register_by_name): Ditto. * server.c (process_serial_event): Adjust. * linux-low.h (regset_fill_func, regset_store_func): Change prototype. (get_pc, set_pc, collect_ptrace_register, supply_ptrace_register): Change prototype. * linux-low.c (get_stop_pc): Adjust. (check_removed_breakpoint): Adjust. (linux_wait_for_event): Adjust. (linux_resume_one_lwp): Adjust. (fetch_register): Add regcache parameter. Adjust. (usr_store_inferior_registers): Ditto. (regsets_fetch_inferior_registers): Ditto. (regsets_store_inferior_registers): Ditto. (linux_fetch_registers, linux_store_registers): Ditto. * i387-fp.c (i387_cache_to_fsave): Change prototype to take a regcache. Adjust. (i387_fsave_to_cache, i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * i387-fp.h (i387_cache_to_fsave, i387_fsave_to_cache): Change prototype to take a regcache. (i387_cache_to_fxsave, i387_fxsave_to_cache): Ditto. * remote-utils.c (convert_ascii_to_int, outreg) (prepare_resume_reply): Change prototype to take a regcache. Adjust. * target.h (struct target_ops) <fetch_registers, store_registers>: Change prototype to take a regcache. (fetch_inferior_registers, store_inferior_registers): Change prototype to take a regcache. Adjust. * proc-service.c (ps_lgetregs): Adjust. * linux-x86-low.c (x86_fill_gregset, x86_store_gregset) (x86_fill_fpregset, x86_store_fpregset, x86_fill_fpxregset) (x86_store_fpxregset, x86_get_pc, x86_set_pc): Change prototype to take a regcache. Adjust. * linux-arm-low.c (arm_fill_gregset, arm_store_gregset) (arm_fill_wmmxregset, arm_store_wmmxregset, arm_fill_vfpregset) (arm_store_vfpregset, arm_get_pc, arm_set_pc): (arm_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-cris-low.c (cris_get_pc, cris_set_pc) (cris_cannot_fetch_register): (cris_breakpoint_at): Change prototype to take a regcache. Adjust. * linux-crisv32-low.c (cris_get_pc, cris_set_pc, cris_reinsert_addr, cris_write_data_breakpoint): Change prototype to take a regcache. Adjust. (cris_breakpoint_at, cris_insert_point, cris_remove_point): Adjust. * linux-m32r-low.c (m32r_get_pc, m32r_set_pc): Change prototype to take a regcache. Adjust. * linux-m68k-low.c (m68k_fill_gregset, m68k_store_gregset) (m68k_fill_fpregset, m68k_store_fpregset, m68k_get_pc, (m68k_set_pc): Change prototype to take a regcache. Adjust. * linux-mips-low.c (mips_get_pc): (mips_set_pc): Change prototype to take a regcache. Adjust. (mips_reinsert_addr): Adjust. (mips_collect_register): Change prototype to take a regcache. Adjust. (mips_supply_register): (mips_collect_register_32bit, mips_supply_register_32bit) (mips_fill_gregset, mips_store_gregset, mips_fill_fpregset) (mips_store_fpregset): Ditto. * linux-ppc-low.c (ppc_supply_ptrace_register, ppc_supply_ptrace_register): Ditto. (parse_spufs_run): Adjust. (ppc_get_pc, ppc_set_pc, ppc_fill_gregset, ppc_fill_vsxregset) (ppc_store_vsxregset, ppc_fill_vrregset, ppc_store_vrregset) (ppc_fill_evrregset, ppc_store_evrregset): Change prototype to take a regcache. Adjust. * linux-s390-low.c (s390_collect_ptrace_register) (s390_supply_ptrace_register, s390_fill_gregset, s390_get_pc) (s390_set_pc): Change prototype to take a regcache. Adjust. (s390_arch_setup): Adjust. * linux-sh-low.c (sh_get_pc, sh_breakpoint_at) (sh_fill_gregset): Change prototype to take a regcache. Adjust. * linux-sparc-low.c (sparc_fill_gregset_to_stack) (sparc_fill_gregset, sparc_store_gregset_from_stack) (sparc_store_gregset, sparc_get_pc): Change prototype to take a regcache. Adjust. (sparc_breakpoint_at): Adjust. * linux-xtensa-low.c (xtensa_fill_gregset): (xtensa_store_gregset): (xtensa_fill_xtregset, xtensa_store_xtregset, xtensa_get_pc) (xtensa_set_pc): Change prototype to take a regcache. Adjust. * nto-low.c (nto_fetch_registers, nto_store_registers): Change prototype to take a regcache. Adjust. * win32-arm-low.c (arm_fetch_inferior_register) (arm_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-i386-low.c (i386_fetch_inferior_register) (i386_store_inferior_register): Change prototype to take a regcache. Adjust. * win32-low.c (child_fetch_inferior_registers) (child_store_inferior_registers): Change prototype to take a regcache. Adjust. (win32_wait): Adjust. (win32_fetch_inferior_registers): Change prototype to take a regcache. Adjust. (win32_store_inferior_registers): Adjust. * win32-low.h (struct win32_target_ops) <fetch_inferior_register, store_inferior_register>: Change prototype to take a regcache.
2010-01-20 23:55:38 +01:00
if (the_target->stopped_by_watchpoint != NULL
&& (*the_target->stopped_by_watchpoint) ())
{
CORE_ADDR addr;
int i;
Fix build with GCC 8: strncpy -> memcpy Recent gcc 8 trunk emits the warning below, ../../../binutils-gdb/gdb/gdbserver/remote-utils.c:1204:14: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 6 bytes from a string of the same length [-Werror=stringop-truncation] strncpy (buf, "watch:", 6); ~~~~~~~~^~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1118:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy (cmdtype1 + 1, cmdtype, len - 1); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here len = strlen (cmdtype); ~~~~~~~^~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1120:15: error: ‘char* strncpy(char*, const char*, size_t)’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=] strncpy (cmdtype2, cmdtype, len - 1); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../binutils-gdb/gdb/cli/cli-decode.c:1110:16: note: length computed here len = strlen (cmdtype); ~~~~~~~^~~~~~~~~ ../../binutils-gdb/gdb/cp-namespace.c:1071:11: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Werror=stringop-truncation] strncpy (full_name + scope_length, "::", 2); ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This patch fixes it by using memcpy instead of strncpy. gdb: 2017-11-22 Yao Qi <yao.qi@linaro.org> * cli/cli-decode.c (help_list): Use memcpy instead of strncpy. * cp-namespace.c (cp_lookup_transparent_type_loop): Likewise. gdb/gdbserver: 2017-11-22 Yao Qi <yao.qi@linaro.org> * remote-utils.c (prepare_resume_reply): Use memcpy.
2017-11-22 13:22:11 +01:00
memcpy (buf, "watch:", 6);
buf += 6;
2002-06-11 Daniel Jacobowitz <drow@mvista.com> * gdbserver/thread-db.c: New file. * gdbserver/proc-service.c: New file. * gdbserver/acinclude.m4: New file. * gdbserver/Makefile.in: Add GDBSERVER_LIBS, gdb_proc_service_h, proc-service.o, and thread-db.o. (linux-low.o): Add USE_THREAD_DB. * gdbserver/acconfig.h: Add HAVE_PRGREGSET_T, HAVE_PRFPREGSET_T, HAVE_LWPID_T, HAVE_PSADDR_T, and PRFPREGSET_T_BROKEN. * gdbserver/aclocal.m4: Regenerated. * gdbserver/config.in: Regenerated. * gdbserver/configure: Regenerated. * gdbserver/configure.in: Check for proc_service.h, sys/procfs.h, thread_db.h, and linux/elf.h headrs. Check for lwpid_t, psaddr_t, prgregset_t, prfpregset_t, and PRFPREGSET_T_BROKEN. Introduce srv_thread_depfiles and USE_THREAD_DB. Check for -lthread_db and thread support. * gdbserver/configure.srv: Enable thread_db support for ARM, i386, MIPS, PowerPC, and SuperH. * gdbserver/i387-fp.c: Constify arguments. * gdbserver/i387-fp.h: Likewise. * gdbserver/inferiors.c: (struct thread_info): Renamed from `struct inferior_info'. Remove PID member. Use generic inferior list header. All uses updated. (inferiors, signal_pid): Removed. (all_threads): New variable. (get_thread): Define. (add_inferior_to_list): New function. (for_each_inferior): New function. (change_inferior_id): New function. (add_inferior): Removed. (remove_inferior): New function. (add_thread): New function. (free_one_thread): New function. (remove_thread): New function. (clear_inferiors): Use for_each_inferior and free_one_thread. (find_inferior): New function. (find_inferior_id): New function. (inferior_target_data): Update argument type. (set_inferior_target_data): Likewise. (inferior_regcache_data): Likewise. (set_inferior_regcache_data): Likewise. * gdbserver/linux-low.c (linux_bp_reinsert): Remove. (all_processes, stopping_threads, using_thrads) (struct pending_signals, debug_threads, pid_of): New. (inferior_pid): Replace with macro. (struct inferior_linux_data): Remove. (get_stop_pc, add_process): New functions. (linux_create_inferior): Restore SIGRTMIN+1 before calling exec. Use add_process and add_thread. (linux_attach_lwp): New function, based on old linux_attach. Use add_process and add_thread. Set stop_expected for new threads. (linux_attach): New function. (linux_kill_one_process): New function. (linux_kill): Kill all LWPs. (linux_thread_alive): Use find_inferior_id. (check_removed_breakpoints, status_pending_p): New functions. (linux_wait_for_process): Renamed from linux_wait_for_one_inferior. Update. Use WNOHANG. Wait for cloned processes also. Update process struct for the found process. (linux_wait_for_event): New function. (linux_wait): Use it. Support LWPs. (send_sigstop, wait_for_sigstop, stop_all_processes) (linux_resume_one_process, linux_continue_one_process): New functions. (linux_resume): Support LWPs. (REGISTER_RAW_SIZE): Remove. (fetch_register): Use register_size instead. Call supply_register. (usr_store_inferior_registers): Likewise. Call collect_register. Fix recursive case. (regsets_fetch_inferior_registers): Improve error message. (regsets_store_inferior_registers): Add debugging. (linux_look_up_symbols): Call thread_db_init if USE_THREAD_DB. (unstopped_p, linux_signal_pid): New functions. (linux_target_ops): Add linux_signal_pid. (linux_init_signals): New function. (initialize_low): Call it. Initialize using_threads. * gdbserver/regcache.c (inferior_regcache_data): Add valid flag. (get_regcache): Fetch registers lazily. Add fetch argument and update all callers. (regcache_invalidate_one, regcache_invalidate): New functions. (new_register_cache): Renamed from create_register_cache. Return the new regcache. (free_register_cache): Change argument to a void *. (registers_to_string, registers_from_string): Call get_regcache with fetch flag set. (register_data): Make static. Pass fetch flag to get_regcache. (supply_register): Call get_regcache with fetch flag clear. (collect_register): Call get_regcache with fetch flag set. (collect_register_as_string): New function. * gdbserver/regcache.h: Update. * gdbserver/remote-utils.c (putpkt): Flush after debug output and use stderr. Handle input interrupts while waiting for an ACK. (input_interrupt): Use signal_pid method. (getpkt): Flush after debug output and use stderr. (outreg): Use collect_register_as_string. (new_thread_notify, dead_thread_notify): New functions. (prepare_resume_reply): Check using_threads. Set thread_from_wait and general_thread. (look_up_one_symbol): Flush after debug output. * gdbserver/server.c (step_thread, server_waiting): New variables. (start_inferior): Don't use signal_pid. Update call to mywait. (attach_inferior): Update call to mywait. (handle_query): Handle qfThreadInfo and qsThreadInfo. (main): Don't fetch/store registers explicitly. Use set_desired_inferior. Support proposed ``Hs'' packet. Update calls to mywait. * gdbserver/server.h: Update. (struct inferior_list, struct_inferior_list_entry): New. * gdbserver/target.c (set_desired_inferior): New. (write_inferior_memory): Constify. (mywait): New function. * gdbserver/target.h: Update. (struct target_ops): New signal_pid method. (mywait): Removed macro, added prototype. * gdbserver/linux-low.h (regset_func): Removed. (regset_fill_func, regset_store_func): New. (enum regset_type): New. (struct regset_info): Add type field. Use new operation types. (struct linux_target_ops): stop_pc renamed to get_pc. Add decr_pc_after_break and breakpoint_at. (get_process, get_thread_proess, get_process_thread) (strut process_info, all_processes, linux_attach_lwp) (thread_db_init): New. * gdbserver/linux-arm-low.c (arm_get_pc, arm_set_pc, arm_breakpoint, arm_breakpoint_len, arm_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-i386-low.c (i386_store_gregset, i386_store_fpregset) (i386_store_fpxregset): Constify. (target_regsets): Add new kind identifier. (i386_get_pc): Renamed from i386_stop_pc. Simplify. (i386_set_pc): Add debugging. (i386_breakpoint_at): New function. (the_low_target): Add new members. * gdbserver/linux-mips-low.c (mips_get_pc, mips_set_pc) (mips_breakpoint, mips_breakpoint_len, mips_reinsert_addr) (mips_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-ppc-low.c (ppc_get_pc, ppc_set_pc) (ppc_breakpoint, ppc_breakpoint_len, ppc_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-sh-low.c (sh_get_pc, sh_set_pc) (sh_breakpoint, sh_breakpoint_len, sh_breakpoint_at): New. (the_low_target): Add new members. * gdbserver/linux-x86-64-low.c (target_regsets): Add new kind identifier.
2002-06-11 19:32:40 +02:00
addr = (*the_target->stopped_data_address) ();
2007-07-17 Pedro Alves <pedro_alves@portugalmail.pt> Daniel Jacobowitz <dan@codesourcery.com> * config/i386/cygwin.mt (TDEPFILES): Add solib-target.o. * coff-pe-read.c (read_pe_exported_syms): Delete verbose printf. * NEWS: Mention gdbserver DLL support. * gdb.base/unload.c (dlopen, dlsym, dlclose, dlerror): Define for __WIN32__. (SHLIB_NAME): Delete definition. Always pass dlerror to fprintf. * gdb.base/unload.exp: Use shared library test routines. * inferiors.c (all_dlls, dlls_changed, get_dll): New. (add_thread): Minor cleanups. (clear_inferiors): Move lower in the file. Clear the DLL list. (free_one_dll, match_dll, loaded_dll, unloaded_dll, clear_list): New. * remote-utils.c (prepare_resume_reply): Check dlls_changed. (xml_escape_text): New. * server.c (handle_query): Handle qXfer:libraries:read. Report it for qSupported. (handle_v_cont): Report errors. (gdbserver_version): Update. (main): Correct size of own_buf. Do not report initial DLL events. * server.h (struct dll_info, all_dlls, dlls_changed, loaded_dll) (unloaded_dll, xml_escape_text): New. * win32-low.c (enum target_waitkind): Update comments. (win32_add_one_solib, get_image_name, winapi_EnumProcessModules) (winapi_GetModuleInformation, winapi_GetModuleFileNameExA) (win32_EnumProcessModules, win32_GetModuleInformation) (win32_GetModuleFileNameExA, load_psapi, psapi_get_dll_name) (winapi_CreateToolhelp32Snapshot, winapi_Module32First) (winapi_Module32Next, win32_CreateToolhelp32Snapshot) (win32_Module32First, win32_Module32Next, load_toolhelp) (toolhelp_get_dll_name, handle_load_dll, handle_unload_dll): New. (get_child_debug_event): Handle DLL events. (win32_wait): Likewise.
2007-07-17 14:51:41 +02:00
/* Convert each byte of the address into two hexadecimal
chars. Note that we take sizeof (void *) instead of
sizeof (addr); this is to avoid sending a 64-bit
address to a 32-bit GDB. */
for (i = sizeof (void *) * 2; i > 0; i--)
*buf++ = tohex ((addr >> (i - 1) * 4) & 0xf);
*buf++ = ';';
}
else if (cs.swbreak_feature && target_stopped_by_sw_breakpoint ())
{
sprintf (buf, "swbreak:;");
buf += strlen (buf);
}
else if (cs.hwbreak_feature && target_stopped_by_hw_breakpoint ())
{
sprintf (buf, "hwbreak:;");
buf += strlen (buf);
}
while (*regp)
{
[GDBserver] Multi-process + multi-arch This patch makes GDBserver support multi-process + biarch. Currently, if you're debugging more than one process at once with a single gdbserver (in extended-remote mode), then all processes must have the same architecture (e.g., 64-bit vs 32-bit). Otherwise, you see this: Added inferior 2 [Switching to inferior 2 [<null>] (<noexec>)] Reading symbols from /home/pedro/gdb/tests/main32...done. Temporary breakpoint 2 at 0x4004cf: main. (2 locations) Starting program: /home/pedro/gdb/tests/main32 warning: Selected architecture i386 is not compatible with reported target architecture i386:x86-64 warning: Architecture rejected target-supplied description Remote 'g' packet reply is too long: 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000090cfffff0000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000000000000000b042f7460000000000020000230000002b0000002b0000002b000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000007f03000000000000ffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000801f00003b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ... etc, etc ... Even though the process was running a 32-bit program, GDBserver sent back to GDB a register set in 64-bit layout. A patch (http://sourceware.org/ml/gdb-patches/2012-11/msg00228.html) a while ago made GDB track a target_gdbarch per inferior, and as consequence, fetch a target description per-inferior. This patch is the GDBserver counterpart, that makes GDBserver keep track of each process'es XML target description and register layout. So in the example above, GDBserver will send the correct register set in 32-bit layout to GDB. A new "struct target_desc" object (tdesc for short) is added, that holds the target description and register layout information about each process. Each `struct process_info' holds a pointer to a target description. The regcache also gains a pointer to a target description, mainly for convenience, and parallel with GDB (and possible future support for programs that flip processor modes). The low target's arch_setup routines are responsible for setting the process'es correct tdesc. This isn't that much different to how things were done before, except that instead of detecting the inferior process'es architecture and calling the corresponding init_registers_FOO routine, which would change the regcache layout globals and recreate the threads' regcaches, the regcache.c globals are gone, and the init_registers_$BAR routines now each initialize a separate global struct target_desc object (one for each arch variant GDBserver supports), and so all the init_registers_$BAR routines that are built into GDBserver are called early at GDBserver startup time (similarly to how GDB handles its built-in target descriptions), and then the arch_setup routine is responsible for making process_info->tdesc point to one of these target description globals. The regcache module is all parameterized to get the regcache's layout from the tdesc object instead of the old register_bytes, etc. globals. The threads' regcaches are now created lazily. The old scheme where we created each of them when we added a new thread doesn't work anymore, because we add the main thread/lwp before we see it stop for the first time, and it is only when we see the thread stop for the first time that we have a chance of determining the inferior's architecture (through the_low_target.arch_setup). Therefore when we add the main thread we don't know which architecture/tdesc its regcache should have. This patch makes the gdb.multi/multi-arch.exp test now pass against (extended-remote) GDBserver. It currently fails, without this patch. The IPA also uses the regcache, so it gains a new global struct target_desc pointer, which points at the description of the process it is loaded in. Re. the linux-low.c & friends changes. Since the register map etc. may differ between processes (64-bit vs 32-bit) etc., the linux_target_ops num_regs, regmap and regset_bitmap data fields are no longer sufficient. A new method is added in their place that returns a pointer to a new struct that includes all info linux-low.c needs to access registers of the current inferior. The patch/discussion that originally introduced linux-low.c:disabled_regsets mentions that the disabled_regsets set may be different per mode (in a biarch setup), and indeed that is cleared whenever we start a new (first) inferior, so that global is moved as well behind the new `struct regs_info'. On the x86 side: I simply replaced the i387-fp.c:num_xmm_registers global with a check for 64-bit or 32-bit process, which is equivalent to how the global was set. This avoided coming up with some more general mechanism that would work for all targets that use this module (GNU/Linux, Windows, etc.). Tested: GNU/Linux IA64 GNU/Linux MIPS64 GNU/Linux PowerPC (Fedora 16) GNU/Linux s390x (Fedora 16) GNU/Linux sparc64 (Debian) GNU/Linux x86_64, -m64 and -m32 (Fedora 17) Cross built, and smoke tested: i686-w64-mingw32, under Wine. GNU/Linux TI C6x, by Yao Qi. Cross built but otherwise not tested: aarch64-linux-gnu arm-linux-gnu m68k-linux nios2-linux-gnu sh-linux-gnu spu tilegx-unknown-linux-gnu Completely untested: GNU/Linux Blackfin GNU/Linux CRIS GNU/Linux CRISv32 GNU/Linux TI Xtensa GNU/Linux M32R LynxOS QNX NTO gdb/gdbserver/ 2013-06-07 Pedro Alves <palves@redhat.com> * Makefile.in (OBS): Add tdesc.o. (IPA_OBJS): Add tdesc-ipa.o. (tdesc-ipa.o): New rule. * ax.c (gdb_eval_agent_expr): Adjust register_size call to new interface. * linux-low.c (new_inferior): Delete. (disabled_regsets, num_regsets): Delete. (linux_add_process): Adjust to set the new per-process new_inferior flag. (linux_detach_one_lwp): Adjust to call regcache_invalidate_thread. (linux_wait_for_lwp): Adjust. Only call arch_setup if the event was a stop. When calling arch_setup, switch the current inferior to the thread that got an event. (linux_resume_one_lwp): Adjust to call regcache_invalidate_thread. (regsets_fetch_inferior_registers) (regsets_store_inferior_registers): New regsets_info parameter. Adjust to use it. (linux_register_in_regsets): New regs_info parameter. Adjust to use it. (register_addr, fetch_register, store_register): New usrregs_info parameter. Adjust to use it. (usr_fetch_inferior_registers, usr_store_inferior_registers): New parameter regs_info. Adjust to use it. (linux_fetch_registers): Get the current inferior's regs_info, and adjust to use it. (linux_store_registers): Ditto. [HAVE_LINUX_REGSETS] (initialize_regsets_info): New. (initialize_low): Don't initialize the target_regsets here. Call initialize_low_arch. * linux-low.h (target_regsets): Delete declaration. (struct regsets_info): New. (struct usrregs_info): New. (struct regs_info): New. (struct process_info_private) <new_inferior>: New field. (struct linux_target_ops): Delete the num_regs, regmap, and regset_bitmap fields. New field regs_info. [HAVE_LINUX_REGSETS] (initialize_regsets_info): Declare. * i387-fp.c (num_xmm_registers): Delete. (i387_cache_to_fsave, i387_fsave_to_cache): Adjust find_regno calls to new interface. (i387_cache_to_fxsave, i387_cache_to_xsave, i387_fxsave_to_cache) (i387_xsave_to_cache): Adjust find_regno calls to new interface. Infer the number of xmm registers from the regcache's target description. * i387-fp.h (num_xmm_registers): Delete. * inferiors.c (add_thread): Don't install the thread's regcache here. * proc-service.c (gregset_info): Fetch the current inferior's regs_info. Adjust to use it. * regcache.c: Include tdesc.h. (register_bytes, reg_defs, num_registers) (gdbserver_expedite_regs): Delete. (get_thread_regcache): If the thread doesn't have a regcache yet, create one, instead of aborting gdbserver. (regcache_invalidate_one): Rename to ... (regcache_invalidate_thread): ... this. (regcache_invalidate_one): New. (regcache_invalidate): Only invalidate registers of the current process. (init_register_cache): Add target_desc parameter, and use it. (new_register_cache): Ditto. Assert the target description has a non zero registers_size. (regcache_cpy): Add assertions. Adjust. (realloc_register_cache, set_register_cache): Delete. (registers_to_string, registers_from_string): Adjust. (find_register_by_name, find_regno, find_register_by_number) (register_cache_size): Add target_desc parameter, and use it. (free_register_cache_thread, free_register_cache_thread_one) (regcache_release, register_cache_size): New. (register_size): Add target_desc parameter, and use it. (register_data, supply_register, supply_register_zeroed) (supply_regblock, supply_register_by_name, collect_register) (collect_register_as_string, collect_register_by_name): Adjust. * regcache.h (struct target_desc): Forward declare. (struct regcache) <tdesc>: New field. (init_register_cache, new_register_cache): Add target_desc parameter. (regcache_invalidate_thread): Declare. (regcache_invalidate_one): Delete declaration. (regcache_release): Declare. (find_register_by_number, register_cache_size, register_size) (find_regno): Add target_desc parameter. (gdbserver_expedite_regs, gdbserver_xmltarget): Delete declarations. * remote-utils.c: Include tdesc.h. (outreg, prepare_resume_reply): Adjust. * server.c: Include tdesc.h. (gdbserver_xmltarget): Delete declaration. (get_features_xml, process_serial_event): Adjust. * server.h [IN_PROCESS_AGENT] (struct target_desc): Forward declare. (struct process_info) <tdesc>: New field. (ipa_tdesc): Declare. * tdesc.c: New file. * tdesc.h: New file. * tracepoint.c: Include tdesc.h. [IN_PROCESS_AGENT] (ipa_tdesc): Define. (get_context_regcache): Adjust to pass ipa_tdesc down. (do_action_at_tracepoint): Adjust to get the register cache size from the context regcache's description. (traceframe_walk_blocks): Adjust to get the register cache size from the current trace frame's description. (traceframe_get_pc): Adjust to get current trace frame's description and pass it down. (gdb_collect): Adjust to get the register cache size from the IPA's description. * linux-amd64-ipa.c (tdesc_amd64_linux): Declare. (gdbserver_xmltarget): Delete. (initialize_low_tracepoint): Set the ipa's target description. * linux-i386-ipa.c (tdesc_i386_linux): Declare. (initialize_low_tracepoint): Set the ipa's target description. * linux-x86-low.c: Include tdesc.h. [__x86_64__] (is_64bit_tdesc): New. (ps_get_thread_area, x86_get_thread_area): Use it. (i386_cannot_store_register): Rename to ... (x86_cannot_store_register): ... this. Use is_64bit_tdesc. (i386_cannot_fetch_register): Rename to ... (x86_cannot_fetch_register): ... this. Use is_64bit_tdesc. (x86_fill_gregset, x86_store_gregset): Adjust register_size calls to new interface. (target_regsets): Rename to ... (x86_regsets): ... this. (x86_get_pc, x86_set_pc): Adjust register_size calls to new interface. (x86_siginfo_fixup): Use is_64bit_tdesc. [__x86_64__] (tdesc_amd64_linux, tdesc_amd64_avx_linux) (tdesc_x32_avx_linux, tdesc_x32_linux) (tdesc_i386_linux, tdesc_i386_mmx_linux, tdesc_i386_avx_linux): Declare. (x86_linux_update_xmltarget): Delete. (I386_LINUX_XSAVE_XCR0_OFFSET): Define. (have_ptrace_getfpxregs, have_ptrace_getregset): New. (AMD64_LINUX_USER64_CS): New. (x86_linux_read_description): New, based on x86_linux_update_xmltarget. (same_process_callback): New. (x86_arch_setup_process_callback): New. (x86_linux_update_xmltarget): New. (x86_regsets_info): New. (amd64_linux_regs_info): New. (i386_linux_usrregs_info): New. (i386_linux_regs_info): New. (x86_linux_regs_info): New. (x86_arch_setup): Reimplement. (x86_install_fast_tracepoint_jump_pad): Use is_64bit_tdesc. (x86_emit_ops): Ditto. (the_low_target): Adjust. Install x86_linux_regs_info, x86_cannot_fetch_register, and x86_cannot_store_register. (initialize_low_arch): New. * linux-ia64-low.c (tdesc_ia64): Declare. (ia64_fetch_register): Adjust. (ia64_usrregs_info, regs_info): New globals. (ia64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sparc-low.c (tdesc_sparc64): Declare. (sparc_fill_gregset_to_stack, sparc_store_gregset_from_stack): Adjust. (sparc_arch_setup): New function. (sparc_regsets_info, sparc_usrregs_info, regs_info): New globals. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-ppc-low.c (tdesc_powerpc_32l, tdesc_powerpc_altivec32l) (tdesc_powerpc_cell32l, tdesc_powerpc_vsx32l) (tdesc_powerpc_isa205_32l, tdesc_powerpc_isa205_altivec32l) (tdesc_powerpc_isa205_vsx32l, tdesc_powerpc_e500l) (tdesc_powerpc_64l, tdesc_powerpc_altivec64l) (tdesc_powerpc_cell64l, tdesc_powerpc_vsx64l) (tdesc_powerpc_isa205_64l, tdesc_powerpc_isa205_altivec64l) (tdesc_powerpc_isa205_vsx64l): Declare. (ppc_cannot_store_register, ppc_collect_ptrace_register) (ppc_supply_ptrace_register, parse_spufs_run, ppc_get_pc) (ppc_set_pc, ppc_get_hwcap): Adjust. (ppc_usrregs_info): Forward declare. (!__powerpc64__) ppc_regmap_adjusted: New global. (ppc_arch_setup): Adjust to the current process'es target description. (ppc_fill_vsxregset, ppc_store_vsxregset, ppc_fill_vrregset) (ppc_store_vrregset, ppc_fill_evrregset, ppc_store_evrregse) (ppc_store_evrregset): Adjust. (target_regsets): Rename to ... (ppc_regsets): ... this, and make static. (ppc_usrregs_info, ppc_regsets_info, regs_info): New globals. (ppc_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-s390-low.c (tdesc_s390_linux32, tdesc_s390_linux32v1) (tdesc_s390_linux32v2, tdesc_s390_linux64, tdesc_s390_linux64v1) (tdesc_s390_linux64v2, tdesc_s390x_linux64, tdesc_s390x_linux64v1) (tdesc_s390x_linux64v2): Declare. (s390_collect_ptrace_register, s390_supply_ptrace_register) (s390_fill_gregset, s390_store_last_break): Adjust. (target_regsets): Rename to ... (s390_regsets): ... this, and make static. (s390_get_pc, s390_set_pc): Adjust. (s390_get_hwcap): New target_desc parameter, and use it. [__s390x__] (have_hwcap_s390_high_gprs): New global. (s390_arch_setup): Adjust to set the current process'es target description. Don't adjust the regmap. (s390_usrregs_info, s390_regsets_info, regs_info): New globals. [__s390x__] (s390_usrregs_info_3264, s390_regsets_info_3264) (regs_info_3264): New globals. (s390_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-mips-low.c (tdesc_mips_linux, tdesc_mips_dsp_linux) (tdesc_mips64_linux, tdesc_mips64_dsp_linux): Declare. [__mips64] (init_registers_mips_linux) (init_registers_mips_dsp_linux): Delete defines. [__mips64] (tdesc_mips_linux, tdesc_mips_dsp_linux): New defines. (have_dsp): New global. (mips_read_description): New, based on mips_arch_setup. (mips_arch_setup): Reimplement. (get_usrregs_info): New function. (mips_cannot_fetch_register, mips_cannot_store_register) (mips_get_pc, mips_set_pc, mips_fill_gregset, mips_store_gregset) (mips_fill_fpregset, mips_store_fpregset): Adjust. (target_regsets): Rename to ... (mips_regsets): ... this, and make static. (mips_regsets_info, mips_dsp_usrregs_info, mips_usrregs_info) (dsp_regs_info, regs_info): New globals. (mips_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-arm-low.c (tdesc_arm, tdesc_arm_with_iwmmxt) (tdesc_arm_with_vfpv2, tdesc_arm_with_vfpv3, tdesc_arm_with_neon): Declare. (arm_fill_vfpregset, arm_store_vfpregset): Adjust. (arm_read_description): New, with bits factored from arm_arch_setup. (arm_arch_setup): Reimplement. (target_regsets): Rename to ... (arm_regsets): ... this, and make static. (arm_regsets_info, arm_usrregs_info, regs_info): New globals. (arm_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m68k-low.c (tdesc_m68k): Declare. (target_regsets): Rename to ... (m68k_regsets): ... this, and make static. (m68k_regsets_info, m68k_usrregs_info, regs_info): New globals. (m68k_regs_info): New function. (m68k_arch_setup): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-sh-low.c (tdesc_sharch): Declare. (target_regsets): Rename to ... (sh_regsets): ... this, and make static. (sh_regsets_info, sh_usrregs_info, regs_info): New globals. (sh_regs_info, sh_arch_setup): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-bfin-low.c (tdesc_bfin): Declare. (bfin_arch_setup): New function. (bfin_usrregs_info, regs_info): New globals. (bfin_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_cris): Declare. (cris_arch_setup): New function. (cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-cris-low.c (tdesc_crisv32): Declare. (cris_arch_setup): New function. (cris_regsets_info, cris_usrregs_info, regs_info): New globals. (cris_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-m32r-low.c (tdesc_m32r): Declare. (m32r_arch_setup): New function. (m32r_usrregs_info, regs_info): New globals. (m32r_regs_info): Adjust. (initialize_low_arch): New function. * linux-tic6x-low.c (tdesc_tic6x_c64xp_linux) (tdesc_tic6x_c64x_linux, tdesc_tic6x_c62x_linux): Declare. (tic6x_usrregs_info): Forward declare. (tic6x_read_description): New function, based on ... (tic6x_arch_setup): ... this. Reimplement. (target_regsets): Rename to ... (tic6x_regsets): ... this, and make static. (tic6x_regsets_info, tic6x_usrregs_info, regs_info): New globals. (tic6x_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-xtensa-low.c (tdesc_xtensa): Declare. (xtensa_fill_gregset, xtensa_store_gregset): Adjust. (target_regsets): Rename to ... (xtensa_regsets): ... this, and make static. (xtensa_regsets_info, xtensa_usrregs_info, regs_info): New globals. (xtensa_arch_setup, xtensa_regs_info): New functions. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-nios2-low.c (tdesc_nios2_linux): Declare. (nios2_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (nios2_regsets): ... this. (nios2_regsets_info, nios2_usrregs_info, regs_info): New globals. (nios2_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-aarch64-low.c (tdesc_aarch64): Declare. (aarch64_arch_setup): Set the current process'es tdesc. (target_regsets): Rename to ... (aarch64_regsets): ... this. (aarch64_regsets_info, aarch64_usrregs_info, regs_info): New globals. (aarch64_regs_info): New function. (the_low_target): Adjust. (initialize_low_arch): New function. * linux-tile-low.c (tdesc_tilegx, tdesc_tilegx32): Declare globals. (target_regsets): Rename to ... (tile_regsets): ... this. (tile_regsets_info, tile_usrregs_info, regs_info): New globals. (tile_regs_info): New function. (tile_arch_setup): Set the current process'es tdesc. (the_low_target): Adjust. (initialize_low_arch): New function. * spu-low.c (tdesc_spu): Declare. (spu_create_inferior, spu_attach): Set the new process'es tdesc. * win32-arm-low.c (tdesc_arm): Declare. (arm_arch_setup): New function. (the_low_target): Install arm_arch_setup instead of init_registers_arm. * win32-i386-low.c (tdesc_i386, tdesc_amd64): Declare. (init_windows_x86): Rename to ... (i386_arch_setup): ... this. Set `win32_tdesc'. (the_low_target): Adjust. * win32-low.c (win32_tdesc): New global. (child_add_thread): Don't create the thread cache here. (do_initial_child_stuff): Set the new process'es tdesc. * win32-low.h (struct target_desc): Forward declare. (win32_tdesc): Declare. * lynx-i386-low.c (tdesc_i386): Declare global. (lynx_i386_arch_setup): Set `lynx_tdesc'. * lynx-low.c (lynx_tdesc): New global. (lynx_add_process): Set the new process'es tdesc. * lynx-low.h (struct target_desc): Forward declare. (lynx_tdesc): Declare global. * lynx-ppc-low.c (tdesc_powerpc_32): Declare global. (lynx_ppc_arch_setup): Set `lynx_tdesc'. * nto-low.c (nto_tdesc): New global. (do_attach): Set the new process'es tdesc. * nto-low.h (struct target_desc): Forward declare. (nto_tdesc): Declare. * nto-x86-low.c (tdesc_i386): Declare. (nto_x86_arch_setup): Set `nto_tdesc'. gdb/ 2013-06-07 Pedro Alves <palves@redhat.com> * regformats/regdat.sh: Output #include tdesc.h. Make globals static. Output a global target description pointer. (init_registers_${name}): Adjust to initialize a target description structure.
2013-06-07 12:46:59 +02:00
buf = outreg (regcache, find_regno (regcache->tdesc, *regp), buf);
regp ++;
}
*buf = '\0';
/* Formerly, if the debugger had not used any thread features
we would not burden it with a thread status response. This
was for the benefit of GDB 4.13 and older. However, in
recent GDB versions the check (``if (cont_thread != 0)'')
does not have the desired effect because of sillyness in
the way that the remote protocol handles specifying a
thread. Since thread support relies on qSymbol support
anyway, assume GDB can handle threads. */
if (using_threads && !disable_packet_Tthread)
{
/* This if (1) ought to be unnecessary. But remote_wait
in GDB will claim this event belongs to inferior_ptid
if we do not specify a thread, and there's no way for
gdbserver to know what inferior_ptid is. */
2018-06-11 22:45:22 +02:00
if (1 || cs.general_thread != 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
int core = -1;
Non-stop mode support. * server.h (non_stop): Declare. (gdb_client_data, handler_func): Declare. (delete_file_handler, add_file_handler, start_event_loop): Declare. (handle_serial_event, handle_target_event, push_event) (putpkt_notif): Declare. * target.h (enum resume_kind): New. (struct thread_resume): Replace `step' field by `kind' field. (TARGET_WNOHANG): Define. (struct target_ops) <wait>: Add `options' argument. <supports_non_stop, async, start_non_stop>: New fields. (target_supports_non_stop, target_async): New. (start_non_stop): Declare. (mywait): Add `options' argument. * target.c (mywait): Add `options' argument. Print child exit notifications here. (start_non_stop): New. * server.c (non_stop, own_buf, mem_buf): New globals. (struct vstop_notif): New. (notif_queue): New global. (queue_stop_reply, push_event, discard_queued_stop_replies) (send_next_stop_reply): New. (start_inferior): Adjust to use resume_kind. Adjust to mywait interface changes. (attach_inferior): In non-stop mode, don't wait for the target here. (handle_general_set): Handle QNonStop. (handle_query): When handling qC, return the current general thread, instead of the first thread of the list. (handle_query): If the backend supports non-stop mode, include QNonStop+ in the qSupported query response. (handle_v_cont): Adjust to use resume_kind. Handle resume_stop and non-stop mode. (handle_v_attach, handle_v_run): Handle non-stop mode. (handle_v_stopped): New. (handle_v_requests): Report support for vCont;t. Handle vStopped. (myresume): Adjust to use resume_kind. Handle non-stop. (queue_stop_reply_callback): New. (handle_status): Handle non-stop mode. (main): Clear non_stop flag on reconnection. Use the event-loop. Refactor serial protocol handling from here ... (process_serial_event): ... to this new function. When GDB selects any thread, select one here. In non-stop mode, wait until GDB acks all pending events before exiting. (handle_serial_event, handle_target_event): New. * remote-utils.c (remote_open): Install remote_desc in the event loop. (remote_close): Remove remote_desc from the event loop. (putpkt_binary): Rename to... (putpkt_binary_1): ... this. Add `is_notic' argument. Handle it. (putpkt_binary): New as wrapper around putpkt_binary_1. (putpkt_notif): New. (prepare_resume_reply): In non-stop mode, don't change the general_thread. * event-loop.c: New. * Makefile.in (OBJ): Add event-loop.o. (event-loop.o): New rule. * linux-low.h (pid_of): Moved here. (lwpid_of): New. (get_lwp_thread): Use lwpid_of. (struct lwp_info): Delete `lwpid' field. Add `suspended' field. * linux-low.c (pid_of): Delete. (inferior_pid): Use lwpid_of. (linux_event_pipe): New. (target_is_async_p): New. (delete_lwp): New. (handle_extended_wait): Use lwpid_of. (add_lwp): Don't set lwpid field. (linux_attach_lwp): Adjust debug output. Use lwpid_of. (linux_kill_one_lwp): If killing a running lwp, stop it first. Use lwpid_of. Adjust to linux_wait_for_event interface changes. (linux_detach_one_lwp): If detaching from a running lwp, stop it first. Adjust to linux_wait_for_event interface changes. Use lwpid_of. (linux_detach): Don't delete the main lwp here. (linux_join): Use my_waitpid. Avoid signal_pid. Use lwpid_of. (status_pending_p): Don't consider explicitly suspended lwps. (linux_wait_for_lwp): Take an integer pid instead of a lwp_info pointer. Add OPTIONS argument. Change return type to int. Use my_waitpid instead of sleeping. Handle WNOHANG. Use lwpid_of. (linux_wait_for_event): Take an integer pid instead of a lwp_info pointer. Add status pointer argument. Return a pid instead of a status. Use lwpid_of. Adjust to linux_wait_for_lwp interface changes. In non-stop mode, don't switch to a random thread. (linux_wait): Rename to... (linux_wait_1): ... this. Add target_options argument, and handle it. Adjust to use resume_kind. Use lwpid_of. In non-stop mode, don't handle the continue thread. Handle TARGET_WNOHANG. Merge clean exit and signal exit code. Don't stop all threads in non-stop mode. In all-stop mode, only stop all threads when reporting a stop to GDB. Handle explicit thread stop requests. (async_file_flush, async_file_mark): New. (linux_wait): New. (send_sigstop): Use lwpid_of. (wait_for_sigstop): Use lwpid_of. Adjust to linux_wait_for_event interface changes. In non-stop mode, don't switch to a random thread. (linux_resume_one_lwp): Use lwpid_of. (linux_continue_one_thread, linux_queue_one_thread): Merge into ... (linux_resume_one_thread): ... this. Handle resume_stop. In non-stop mode, don't look for pending flag in all threads. (resume_status_pending_p): Don't consider explicitly suspended threads. (my_waitpid): Reimplement. Emulate __WALL. (linux_request_interrupt, linux_read_offsets, linux_xfer_siginfo): Use lwpid_of. (sigchld_handler, linux_supports_non_stop, linux_async) (linux_start_non_stop): New. (linux_target_ops): Register linux_supports_non_stop, linux_async and linux_start_non_stop. (initialize_low): Install SIGCHLD handler. * thread-db.c (thread_db_create_event, find_one_thread) (thread_db_get_tls_address): Use lwpid_of. * win32-low.c (win32_detach): Adjust to use resume_kind. (win32_wait): Add `options' argument. * spu-low.c (spu_resume): Adjust to use resume_kind. (spu_wait): Add `options' argument.
2009-04-02 00:48:05 +02:00
/* In non-stop, don't change the general thread behind
GDB's back. */
if (!non_stop)
cs.general_thread = ptid;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sprintf (buf, "thread:");
buf += strlen (buf);
buf = write_ptid (buf, ptid);
strcat (buf, ";");
buf += strlen (buf);
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
core = target_core_of_thread (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
if (core != -1)
{
sprintf (buf, "core:");
buf += strlen (buf);
sprintf (buf, "%x", core);
strcat (buf, ";");
buf += strlen (buf);
}
}
}
if (dlls_changed)
{
strcpy (buf, "library:;");
buf += strlen (buf);
dlls_changed = 0;
}
Rename current_inferior as current_thread in gdbserver GDB has a function named "current_inferior" and gdbserver has a global variable named "current_inferior", but the two are not equivalent; indeed, gdbserver does not have any real equivalent of what GDB calls an inferior. What gdbserver's "current_inferior" is actually pointing to is a structure describing the current thread. This commit renames current_inferior as current_thread in gdbserver to clarify this. It also renames the function "set_desired_inferior" to "set_desired_thread" and renames various local variables from foo_inferior to foo_thread. gdb/gdbserver/ChangeLog: * inferiors.h (current_inferior): Renamed as... (current_thread): New variable. All uses updated. * linux-low.c (get_pc): Renamed saved_inferior as saved_thread. (maybe_move_out_of_jump_pad): Likewise. (cancel_breakpoint): Likewise. (linux_low_filter_event): Likewise. (wait_for_sigstop): Likewise. (linux_resume_one_lwp): Likewise. (need_step_over_p): Likewise. (start_step_over): Likewise. (linux_stabilize_threads): Renamed save_inferior as saved_thread. * linux-x86-low.c (x86_linux_update_xmltarget): Likewise. * proc-service.c (ps_lgetregs): Renamed reg_inferior as reg_thread and save_inferior as saved_thread. * regcache.c (get_thread_regcache): Renamed saved_inferior as saved_thread. (regcache_invalidate_thread): Likewise. * remote-utils.c (prepare_resume_reply): Likewise. * thread-db.c (thread_db_get_tls_address): Likewise. (disable_thread_event_reporting): Likewise. (remove_thread_event_breakpoints): Likewise. * tracepoint.c (gdb_agent_about_to_close): Renamed save_inferior as saved_thread. * target.h (set_desired_inferior): Renamed as... (set_desired_thread): New declaration. All uses updated. * server.c (myresume): Updated comment to reference thread instead of inferior. (handle_serial_event): Likewise. (handle_target_event): Likewise.
2014-09-10 11:37:11 +02:00
current_thread = saved_thread;
}
break;
case TARGET_WAITKIND_EXITED:
if (cs.multi_process)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sprintf (buf, "W%x;process:%x",
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
status->value.integer, ptid.pid ());
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
else
sprintf (buf, "W%02x", status->value.integer);
break;
case TARGET_WAITKIND_SIGNALLED:
if (cs.multi_process)
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sprintf (buf, "X%x;process:%x",
Remove ptid_get_pid This removes ptid_get_pid in favor of calling the ptid_t::pid method. gdb/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * common/ptid.c (ptid_get_pid): Remove. * common/ptid.h (ptid_get_pid): Don't declare. * aarch64-linux-nat.c: Update. * ada-lang.c: Update. * aix-thread.c: Update. * alpha-bsd-nat.c: Update. * amd64-fbsd-nat.c: Update. * amd64-linux-nat.c: Update. * arm-linux-nat.c: Update. * arm-nbsd-nat.c: Update. * auxv.c: Update. * break-catch-syscall.c: Update. * breakpoint.c: Update. * bsd-uthread.c: Update. * corelow.c: Update. * ctf.c: Update. * darwin-nat.c: Update. * fbsd-nat.c: Update. * fbsd-tdep.c: Update. * gcore.c: Update. * gnu-nat.c: Update. * hppa-nbsd-nat.c: Update. * hppa-obsd-nat.c: Update. * i386-fbsd-nat.c: Update. * ia64-linux-nat.c: Update. * inf-ptrace.c: Update. * infcmd.c: Update. * inferior.c: Update. * inferior.h: Update. * inflow.c: Update. * infrun.c: Update. * linux-fork.c: Update. * linux-nat.c: Update. * linux-tdep.c: Update. * linux-thread-db.c: Update. * m68k-bsd-nat.c: Update. * mi/mi-interp.c: Update. * mi/mi-main.c: Update. * mips-linux-nat.c: Update. * mips-nbsd-nat.c: Update. * mips64-obsd-nat.c: Update. * nat/aarch64-linux-hw-point.c: Update. * nat/aarch64-linux.c: Update. * nat/linux-btrace.c: Update. * nat/linux-osdata.c: Update. * nat/linux-procfs.c: Update. * nat/x86-linux-dregs.c: Update. * nto-procfs.c: Update. * obsd-nat.c: Update. * ppc-linux-nat.c: Update. * ppc-nbsd-nat.c: Update. * ppc-obsd-nat.c: Update. * proc-service.c: Update. * procfs.c: Update. * python/py-inferior.c: Update. * python/py-infthread.c: Update. * ravenscar-thread.c: Update. * record.c: Update. * remote-sim.c: Update. * remote.c: Update. * rs6000-nat.c: Update. * s390-linux-nat.c: Update. * sh-nbsd-nat.c: Update. * sol-thread.c: Update. * sparc-nat.c: Update. * sparc64-tdep.c: Update. * spu-linux-nat.c: Update. * spu-tdep.c: Update. * target-debug.h: Update. * target.c: Update. * thread.c: Update. * tid-parse.c: Update. * tracefile-tfile.c: Update. * vax-bsd-nat.c: Update. * windows-nat.c: Update. * x86-linux-nat.c: Update. * x86-nat.c: Update. gdb/gdbserver/ChangeLog 2018-07-03 Tom Tromey <tom@tromey.com> * linux-low.c: Update. * linux-mips-low.c: Update. * lynx-low.c: Update. * mem-break.c: Update. * nto-low.c: Update. * remote-utils.c: Update. * server.c: Update. * spu-low.c: Update. * target.c: Update. * tracepoint.c: Update.
2018-06-11 20:05:27 +02:00
status->value.sig, ptid.pid ());
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
else
sprintf (buf, "X%02x", status->value.sig);
break;
Remote thread create/exit events When testing with "maint set target-non-stop on", a few threading-related tests expose an issue that requires new RSP packets. Say there are 3 threads running, 1-3. If GDB tries to stop thread 1, 2 and 3, and then waits for their stops, but meanwhile say, thread 2 exits, GDB hangs forever waiting for a stop for thread 2 that won't ever happen. This patch fixes the issue by adding support for thread exit events to the protocol. However, we don't want these always enabled, as they're useless most of the time, and would slow down remote debugging. So I made it so that GDB can enable/disable them, and then made gdb do that around the cases that need it, which currently is only infrun.c:stop_all_threads. In turn, if we have thread exit events, then the extra "thread x exited" traffic slows down attach-many-short-lived-threads.exp enough that gdb has trouble keeping up with new threads that are spawned while gdb tries to stop existing ones. To fix that I added support for the counterpart thread created events too. Enabling those when we try to stop threads ensures that new threads never get a chance to themselves start new threads, killing the race. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.texinfo (Remote Configuration): List "set/show remote thread-events" command in configuration table. (Stop Reply Packets): Document "T05 create" stop reason and 'w' stop reply. (General Query Packets): Document QThreadEvents packet. Document QThreadEvents qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * linux-low.c (handle_extended_wait): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. If GDB wants to hear about thread create events, leave the new child's status pending. (linux_low_filter_event): If GDB wants to hear about thread exit events, leave the LWP marked dead and don't delete it. (linux_wait_for_event_filtered): Don't check for thread exit. (filter_exit_event): New function. (linux_wait_1): Use it, when returning an exit event. (linux_resume_one_lwp_throw): Assert that the LWP's waitstatus is TARGET_WAITKIND_IGNORE. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.c (report_thread_events): New global. (handle_general_set): Handle QThreadEvents. (handle_query) <qSupported>: Handle and report QThreadEvents+; (handle_target_event): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * server.h (report_thread_events): Declare. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * NEWS (New commands): Mention "set/show remote thread-events" commands. (New remote packets): Mention thread created/exited stop reasons and QThreadEvents packet. * infrun.c (disable_thread_events): New function. (stop_all_threads): Disable/enable thread create/exit events. Handle TARGET_WAITKIND_THREAD_EXITED. (handle_inferior_event_1): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * remote.c (remove_child_of_pending_fork): Also remove threads of threads that have TARGET_WAITKIND_THREAD_EXITED events. (remote_parse_stop_reply): Handle "create" magic register. Handle 'w' stop reply. (initialize_remote): Install remote_thread_events as to_thread_events target hook. (remote_thread_events): New function. * target-delegates.c: Regenerate. * target.c (target_thread_events): New function. * target.h (struct target_ops) <to_thread_events>: New field. (target_thread_events): Declare. * target/waitstatus.c (target_waitstatus_to_string): Handle TARGET_WAITKIND_THREAD_CREATED and TARGET_WAITKIND_THREAD_EXITED. * target/waitstatus.h (enum target_waitkind) <TARGET_WAITKIND_THREAD_CREATED, TARGET_WAITKIND_THREAD_EXITED): New values.
2015-11-30 17:05:21 +01:00
case TARGET_WAITKIND_THREAD_EXITED:
sprintf (buf, "w%x;", status->value.integer);
buf += strlen (buf);
buf = write_ptid (buf, ptid);
break;
Implement TARGET_WAITKIND_NO_RESUMED in the remote protocol Testing with "maint set target-non-stop on" causes regressions in tests that rely on TARGET_WAITKIND_NO_RESUMED, which isn't modelled on the RSP. In real all-stop, gdbserver detects the situation and reporst error to GDB, and so the tests (e.g., gdb.threads/no-unwaited-for-left.exp) at fail quickly. But with "maint set target-non-stop on", GDB instead hangs forever waiting for a stop reply that never comes, and so the tests take longer to time out. This adds a new "N" stop reply packet that maps 1-1 to TARGET_WAITKIND_NO_RESUMED. gdb/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * NEWS (New remote packets): Mention the N stop reply. * remote.c (remote_protocol_features): Add "no-resumed" entry. (remote_query_supported): Report no-resumed+ support. (remote_parse_stop_reply): Handle 'N'. (process_stop_reply): Handle TARGET_WAITKIND_NO_RESUMED. (remote_wait_as): Handle 'N' / TARGET_WAITKIND_NO_RESUMED. (_initialize_remote): Register "set/show remote no-resumed-stop-reply" commands. gdb/doc/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * gdb.texinfo (Stop Reply Packets): Document the N stop reply. (Remote Configuration): Add the "set/show remote no-resumed-stop-reply" to the available settings table. (General Query Packets): Document the "no-resumed" qSupported feature. gdb/gdbserver/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> PR 14618 * linux-low.c (linux_wait_1): If the last resumed thread is gone, report TARGET_WAITKIND_NO_RESUMED. * remote-utils.c (prepare_resume_reply): Handle TARGET_WAITKIND_NO_RESUMED. * server.c (report_no_resumed): New global. (handle_query) <qSupported>: Handle "no-resumed+". Report "no-resumed+" support. (resume): When the target reports TARGET_WAITKIND_NO_RESUMED, only return error if the client doesn't support no-resumed events. (push_stop_notification): New function. (handle_target_event): Use it. Report TARGET_WAITKIND_NO_RESUMED events if the client supports them. gdb/testsuite/ChangeLog: 2015-11-30 Pedro Alves <palves@redhat.com> * gdb.threads/no-unwaited-for-left.exp: Remove setup_kfail calls.
2015-11-30 17:05:25 +01:00
case TARGET_WAITKIND_NO_RESUMED:
sprintf (buf, "N");
break;
default:
error ("unhandled waitkind");
break;
}
}
void
2000-07-30 03:48:28 +02:00
decode_m_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr)
{
int i = 0, j = 0;
char ch;
*mem_addr_ptr = *len_ptr = 0;
while ((ch = from[i++]) != ',')
{
*mem_addr_ptr = *mem_addr_ptr << 4;
*mem_addr_ptr |= fromhex (ch) & 0x0f;
}
for (j = 0; j < 4; j++)
{
if ((ch = from[i++]) == 0)
break;
*len_ptr = *len_ptr << 4;
*len_ptr |= fromhex (ch) & 0x0f;
}
}
void
2000-07-30 03:48:28 +02:00
decode_M_packet (char *from, CORE_ADDR *mem_addr_ptr, unsigned int *len_ptr,
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
unsigned char **to_p)
{
int i = 0;
char ch;
*mem_addr_ptr = *len_ptr = 0;
while ((ch = from[i++]) != ',')
{
*mem_addr_ptr = *mem_addr_ptr << 4;
*mem_addr_ptr |= fromhex (ch) & 0x0f;
}
while ((ch = from[i++]) != ':')
{
*len_ptr = *len_ptr << 4;
*len_ptr |= fromhex (ch) & 0x0f;
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (*to_p == NULL)
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
*to_p = (unsigned char *) xmalloc (*len_ptr);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
hex2bin (&from[i++], *to_p, *len_ptr);
}
int
decode_X_packet (char *from, int packet_len, CORE_ADDR *mem_addr_ptr,
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
unsigned int *len_ptr, unsigned char **to_p)
{
int i = 0;
char ch;
*mem_addr_ptr = *len_ptr = 0;
while ((ch = from[i++]) != ',')
{
*mem_addr_ptr = *mem_addr_ptr << 4;
*mem_addr_ptr |= fromhex (ch) & 0x0f;
}
while ((ch = from[i++]) != ':')
{
*len_ptr = *len_ptr << 4;
*len_ptr |= fromhex (ch) & 0x0f;
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (*to_p == NULL)
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
*to_p = (unsigned char *) xmalloc (*len_ptr);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (remote_unescape_input ((const gdb_byte *) &from[i], packet_len - i,
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
*to_p, *len_ptr) != *len_ptr)
return -1;
return 0;
}
/* Decode a qXfer write request. */
int
decode_xfer_write (char *buf, int packet_len, CORE_ADDR *offset,
unsigned int *len, unsigned char *data)
{
char ch;
char *b = buf;
/* Extract the offset. */
*offset = 0;
while ((ch = *buf++) != ':')
{
*offset = *offset << 4;
*offset |= fromhex (ch) & 0x0f;
}
/* Get encoded data. */
packet_len -= buf - b;
*len = remote_unescape_input ((const gdb_byte *) buf, packet_len,
data, packet_len);
return 0;
}
/* Decode the parameters of a qSearch:memory packet. */
int
decode_search_memory_packet (const char *buf, int packet_len,
CORE_ADDR *start_addrp,
CORE_ADDR *search_space_lenp,
gdb_byte *pattern, unsigned int *pattern_lenp)
{
const char *p = buf;
p = decode_address_to_semicolon (start_addrp, p);
p = decode_address_to_semicolon (search_space_lenp, p);
packet_len -= p - buf;
*pattern_lenp = remote_unescape_input ((const gdb_byte *) p, packet_len,
pattern, packet_len);
return 0;
}
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
static void
free_sym_cache (struct sym_cache *sym)
{
if (sym != NULL)
{
free (sym->name);
free (sym);
}
}
void
clear_symbol_cache (struct sym_cache **symcache_p)
{
struct sym_cache *sym, *next;
/* Check the cache first. */
for (sym = *symcache_p; sym; sym = next)
{
next = sym->next;
free_sym_cache (sym);
}
*symcache_p = NULL;
}
/* Get the address of NAME, and return it in ADDRP if found. if
MAY_ASK_GDB is false, assume symbol cache misses are failures.
Returns 1 if the symbol is found, 0 if it is not, -1 on error. */
int
look_up_one_symbol (const char *name, CORE_ADDR *addrp, int may_ask_gdb)
{
client_state &cs = get_client_state ();
char *p, *q;
int len;
struct sym_cache *sym;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
struct process_info *proc;
proc = current_process ();
/* Check the cache first. */
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
for (sym = proc->symbol_cache; sym; sym = sym->next)
if (strcmp (name, sym->name) == 0)
{
*addrp = sym->addr;
return 1;
}
/* It might not be an appropriate time to look up a symbol,
e.g. while we're trying to fetch registers. */
if (!may_ask_gdb)
return 0;
/* Send the request. */
strcpy (cs.own_buf, "qSymbol:");
bin2hex ((const gdb_byte *) name, cs.own_buf + strlen ("qSymbol:"),
strlen (name));
if (putpkt (cs.own_buf) < 0)
return -1;
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
len = getpkt (cs.own_buf);
if (len < 0)
return -1;
/* We ought to handle pretty much any packet at this point while we
wait for the qSymbol "response". That requires re-entering the
main loop. For now, this is an adequate approximation; allow
GDB to read from memory and handle 'v' packets (for vFile transfers)
while it figures out the address of the symbol. */
while (1)
{
if (cs.own_buf[0] == 'm')
{
CORE_ADDR mem_addr;
unsigned char *mem_buf;
unsigned int mem_len;
decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
mem_buf = (unsigned char *) xmalloc (mem_len);
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
bin2hex (mem_buf, cs.own_buf, mem_len);
else
write_enn (cs.own_buf);
free (mem_buf);
if (putpkt (cs.own_buf) < 0)
return -1;
}
else if (cs.own_buf[0] == 'v')
{
int new_len = -1;
handle_v_requests (cs.own_buf, len, &new_len);
if (new_len != -1)
putpkt_binary (cs.own_buf, new_len);
else
putpkt (cs.own_buf);
}
else
break;
len = getpkt (cs.own_buf);
if (len < 0)
return -1;
}
if (!startswith (cs.own_buf, "qSymbol:"))
{
Remove newlines from warnings ARI pointed out that a recent patch introduced a call to "warning" with a string that ended in a newline: https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html This is generally forbidden, I believe, because warning adds its own newline. This patch removes all of the trailing newlines I was able to find. I searched for 'warning (.*\\n"' and then fixed the ones where the newline appeared at the end of the string (some had internal newlines). Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning with a newline. * guile/guile.c (handle_boot_error): Don't end warning with a newline. * cli/cli-cmds.c (exit_status_set_internal_vars): Don't end warning with a newline. * s12z-tdep.c (s12z_skip_prologue): Don't end warning with a newline. (s12z_frame_cache): Likewise. * dwarf-index-cache.c (index_cache::store): Don't end warning with a newline. * solib-svr4.c (disable_probes_interface): Don't end warning with a newline. * nat/fork-inferior.c (fork_inferior): Don't end warning with a newline. * python/python.c (do_finish_initialization): Don't end warning with a newline. gdb/gdbserver/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * remote-utils.c (look_up_one_symbol, relocate_instruction): Don't end warning with a newline. * linux-s390-low.c (s390_get_wordsize): Don't end warning with a newline. * thread-db.c (attach_thread): Don't end warning with a newline. (thread_db_notice_clone): Likewise. * tracepoint.c (gdb_agent_helper_thread): Don't end warning with a newline. * linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't end warning with a newline.
2019-06-03 16:07:29 +02:00
warning ("Malformed response to qSymbol, ignoring: %s", cs.own_buf);
return -1;
}
p = cs.own_buf + strlen ("qSymbol:");
q = p;
while (*q && *q != ':')
q++;
/* Make sure we found a value for the symbol. */
if (p == q || *q == '\0')
return 0;
decode_address (addrp, p, q - p);
/* Save the symbol in our cache. */
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
sym = XNEW (struct sym_cache);
sym->name = xstrdup (name);
sym->addr = *addrp;
2009-04-01 Pedro Alves <pedro@codesourcery.com> Implement the multiprocess extensions, and add linux multiprocess support. * server.h (ULONGEST): Declare. (struct ptid, ptid_t): New. (minus_one_ptid, null_ptid): Declare. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): Declare. (struct inferior_list_entry): Change `id' type from unsigned from to ptid_t. (struct sym_cache, struct breakpoint, struct process_info_private): Forward declare. (struct process_info): Declare. (current_process): Declare. (all_processes): Declare. (initialize_inferiors): Declare. (add_thread): Adjust to use ptid_t. (thread_id_to_gdb_id, thread_to_gdb_id, gdb_id_to_thread_id): Ditto. (add_process, remove_process, find_thread_pid): Declare. (find_inferior_id): Adjust to use ptid_t. (cont_thread, general_thread, step_thread): Change type to ptid_t. (multi_process): Declare. (push_event): Adjust to use ptid_t. (read_ptid, write_ptid): Declare. (prepare_resume_reply): Adjust to use ptid_t. (clear_symbol_cache): Declare. * inferiors.c (all_processes): New. (null_ptid, minus_one_ptid): New. (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) (ptid_get_tid, ptid_equal, ptid_is_pid): New. (add_thread): Change unsigned long to ptid. Remove gdb_id parameter. Adjust. (thread_id_to_gdb_id, thread_to_gdb_id): Change unsigned long to ptid. (gdb_id_to_thread): Rename to ... (find_thread_pid): ... this. Change unsigned long to ptid. (gdb_id_to_thread_id, find_inferior_id): Change unsigned long to ptid. (loaded_dll, pull_pid_from_list): Adjust. (add_process, remove_process, find_process_pid) (get_thread_process, current_process, initialize_inferiors): New. * target.h (struct thread_resume) <thread>: Change type to ptid_t. (struct target_waitstatus) <related_pid>: Ditto. (struct target_ops) <kill, detach>: Add `pid' argument. Change return type to int. (struct target_ops) <join>: Add `pid' argument. (struct target_ops) <thread_alive>: Change pid's type to ptid_t. (struct target_ops) <wait>: Add `ptid' field. Change return type to ptid. (kill_inferior, detach_inferior, join_inferior): Add `pid' argument. (mywait): Add `ptid' argument. Change return type to ptid_t. (target_pid_to_str): Declare. * target.c (set_desired_inferior): Adjust to use ptids. (mywait): Add new `ptid' argument. Adjust. (target_pid_to_str): New. * mem-break.h (free_all_breakpoints): Declare. * mem-break.c (breakpoints): Delelete. (set_breakpoint_at, delete_breakpoint, find_breakpoint_at) (check_mem_read, check_mem_write, delete_all_breakpoints): Adjust to use per-process breakpoint list. (free_all_breakpoints): New. * remote-utils.c (struct sym_cache) <name>: Drop `const'. (symbol_cache, all_symbols_looked_up): Delete. (hexchars): New. (ishex, unpack_varlen_hex, write_ptid, hex_or_minus_one, read_ptid): New. (prepare_resume_reply): Change ptid argument's type from unsigned long to ptid_t. Adjust. Implement W;process and X;process. (free_sym_cache, clear_symbol_cache): New. (look_up_one_symbol): Adjust to per-process symbol cache. * * server.c (cont_thread, general_thread, step_thread): Change type to ptid_t. (attached): Delete. (multi_process): New. (last_ptid): Change type to ptid_t. (struct vstop_notif) <ptid>: Change type to ptid_t. (queue_stop_reply, push_event): Change `ptid' argument's type to ptid_t. (discard_queued_stop_replies): Add `pid' argument. (start_inferior): Adjust to use ptids. Adjust to mywait interface changes. Don't reference the `attached' global. (attach_inferior): Adjust to mywait interface changes. (handle_query): Adjust to use ptids. Parse GDB's qSupported features. Handle and report "multiprocess+". Handle "qAttached:PID". (handle_v_cont): Adjust to use ptids. Adjust to mywait interface changes. (handle_v_kill): New. (handle_v_stopped): Adjust to use target_pid_to_str. (handle_v_requests): Allow multiple attaches and runs when multiprocess extensions are in effect. Handle "vKill". (myresume): Adjust to use ptids. (queue_stop_reply_callback): Add `arg' parameter. Handle it. (handle_status): Adjust to discard_queued_stop_replies interface change. (first_thread_of, kill_inferior_callback) (detach_or_kill_inferior_callback, join_inferiors_callback): New. (main): Call initialize_inferiors. Adjust to use ptids, killing and detaching from all inferiors. Handle multiprocess packet variants. * linux-low.h: Include gdb_proc_service.h. (struct process_info_private): New. (struct linux_target_ops) <pid_of>: Use ptid_get_pid. <lwpid_of>: Use ptid_get_lwp. (get_lwp_thread): Adjust. (struct lwp_info): Add `dead' member. (find_lwp_pid): Declare. * linux-low.c (thread_db_active): Delete. (new_inferior): Adjust comment. (inferior_pid): Delete. (linux_add_process): New. (handle_extended_wait): Adjust. (add_lwp): Change unsigned long to ptid. (linux_create_inferior): Add process to processes table. Adjust to use ptids. Don't set new_inferior here. (linux_attach_lwp): Rename to ... (linux_attach_lwp_1): ... this. Add `initial' argument. Handle it. Adjust to use ptids. (linux_attach_lwp): New. (linux_attach): Add process to processes table. Don't set new_inferior here. (struct counter): New. (second_thread_of_pid_p, last_thread_of_process_p): New. (linux_kill_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (linux_kill): Add `pid' argument. Handle it. Adjust to multiple processes. Remove process from process table. (linux_detach_one_lwp): Add `args' parameter. Handle it. Adjust to multiple processes. (any_thread_of): New. (linux_detach): Add `pid' argument, and handle it. Remove process from processes table. (linux_join): Add `pid' argument. Handle it. (linux_thread_alive): Change unsighed long argument to ptid_t. Consider dead lwps as not being alive. (status_pending_p): Rename `dummy' argument to `arg'. Filter out threads we're not interested in. (same_lwp, find_lwp_pid): New. (linux_wait_for_lwp): Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): Rename to ... (linux_wait_for_event_1): ... this. Change `pid' argument's type from int to ptid_t. Adjust. (linux_wait_for_event): New. (linux_wait_1): Add `ptid' argument. Change return type to ptid_t. Adjust. Use last_thread_of_process_p. Remove processes that exit from the process table. (linux_wait): Add `ptid' argument. Change return type to ptid_t. Adjust. (mark_lwp_dead): New. (wait_for_sigstop): Adjust to use ptids. If a process exits while stopping all threads, mark its main lwp as dead. (linux_set_resume_request, linux_resume_one_thread): Adjust to use ptids. (fetch_register, usr_store_inferior_registers) (regsets_fetch_inferior_registers) (regsets_store_inferior_registers, linux_read_memory) (linux_write_memory): Inline `inferior_pid'. (linux_look_up_symbols): Adjust to use per-process `thread_db_active'. (linux_request_interrupt): Adjust to use ptids. (linux_read_auxv): Inline `inferior_pid'. (initialize_low): Don't reference thread_db_active. * gdb_proc_service.h (struct ps_prochandle) <pid>: Remove. * proc-service.c (ps_lgetregs): Use find_lwp_pid. (ps_getpid): Return the pid of the current inferior. * thread-db.c (proc_handle, thread_agent): Delete. (thread_db_create_event, thread_db_enable_reporting): Adjust to per-process data. (find_one_thread): Change argument type to ptid_t. Adjust to per-process data. (maybe_attach_thread): Adjust to per-process data and ptids. (thread_db_find_new_threads): Ditto. (thread_db_init): Ditto. * spu-low.c (spu_create_inferior, spu_attach): Add process to processes table. Adjust to use ptids. (spu_kill, spu_detach): Adjust interface. Remove process from processes table. (spu_join, spu_thread_alive): Adjust interface. (spu_wait): Adjust interface. Remove process from processes table. Adjust to use ptids. * win32-low.c (current_inferior_tid): Delete. (current_inferior_ptid): New. (debug_event_ptid): New. (thread_rec): Take a ptid. Adjust. (child_add_thread): Add `pid' argument. Adjust to use ptids. (child_delete_thread): Ditto. (do_initial_child_stuff): Add `attached' argument. Add process to processes table. (child_fetch_inferior_registers, child_store_inferior_registers): Adjust. (win32_create_inferior): Pass 0 to do_initial_child_stuff. (win32_attach): Pass 1 to do_initial_child_stuff. (win32_kill): Adjust interface. Remove process from processes table. (win32_detach): Ditto. (win32_join): Adjust interface. (win32_thread_alive): Take a ptid. (win32_resume): Adjust to use ptids. (get_child_debug_event): Ditto. (win32_wait): Adjust interface. Remove exiting process from processes table.
2009-04-02 00:50:24 +02:00
sym->next = proc->symbol_cache;
proc->symbol_cache = sym;
return 1;
}
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
/* Relocate an instruction to execute at a different address. OLDLOC
is the address in the inferior memory where the instruction to
relocate is currently at. On input, TO points to the destination
where we want the instruction to be copied (and possibly adjusted)
to. On output, it points to one past the end of the resulting
instruction(s). The effect of executing the instruction at TO
shall be the same as if executing it at OLDLOC. For example, call
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
instructions that implicitly push the return address on the stack
should be adjusted to return to the instruction after OLDLOC;
relative branches, and other PC-relative instructions need the
offset adjusted; etc. Returns 0 on success, -1 on failure. */
int
relocate_instruction (CORE_ADDR *to, CORE_ADDR oldloc)
{
client_state &cs = get_client_state ();
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
int len;
ULONGEST written = 0;
/* Send the request. */
sprintf (cs.own_buf, "qRelocInsn:%s;%s", paddress (oldloc),
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
paddress (*to));
if (putpkt (cs.own_buf) < 0)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return -1;
/* FIXME: Eventually add buffer overflow checking (to getpkt?) */
len = getpkt (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (len < 0)
return -1;
/* We ought to handle pretty much any packet at this point while we
wait for the qRelocInsn "response". That requires re-entering
the main loop. For now, this is an adequate approximation; allow
GDB to access memory. */
while (cs.own_buf[0] == 'm' || cs.own_buf[0] == 'M' || cs.own_buf[0] == 'X')
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
CORE_ADDR mem_addr;
unsigned char *mem_buf = NULL;
unsigned int mem_len;
if (cs.own_buf[0] == 'm')
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
decode_m_packet (&cs.own_buf[1], &mem_addr, &mem_len);
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
mem_buf = (unsigned char *) xmalloc (mem_len);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (read_inferior_memory (mem_addr, mem_buf, mem_len) == 0)
bin2hex (mem_buf, cs.own_buf, mem_len);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
else
write_enn (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
else if (cs.own_buf[0] == 'X')
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
if (decode_X_packet (&cs.own_buf[1], len - 1, &mem_addr,
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
&mem_len, &mem_buf) < 0
Replace write_inferior_memory with target_write_memory target_write_memory is just a simple wrapper for write_inferior_memory. Because target_write_memory is needed for gdbsupport, and because gdb uses the name "target_write_memory" everywhere, this patch renames write_inferior_memory and removes the wrapper. I think this brings gdb and gdbserver slightly more in sync. gdb/gdbserver/ChangeLog 2019-08-15 Tom Tromey <tromey@adacore.com> * tracepoint.c (write_inferior_data_pointer) (write_inferior_integer, write_inferior_int8) (write_inferior_uinteger, m_tracepoint_action_download) (r_tracepoint_action_download, x_tracepoint_action_download) (l_tracepoint_action_download, clear_inferior_trace_buffer) (download_agent_expr, download_tracepoint_1) (download_trace_state_variables, upload_fast_traceframes): Update. * server.c (gdb_write_memory): Update. * remote-utils.c (relocate_instruction): Update. * proc-service.c (ps_pdwrite): Update. * mem-break.c (remove_memory_breakpoint) (delete_fast_tracepoint_jump, set_fast_tracepoint_jump) (uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Update. * linux-x86-low.c (append_insns) (i386_install_fast_tracepoint_jump_pad) (amd64_write_goto_address, i386_write_goto_address): Update. * linux-s390-low.c (append_insns, s390_write_goto_address): Update. * linux-ppc-low.c (ppc_relocate_instruction) (ppc_install_fast_tracepoint_jump_pad, emit_insns) (ppc_write_goto_address): Update. * linux-aarch64-low.c (append_insns): Update. * target.h (struct target_ops): Update. (write_inferior_memory): Don't declare. * target.c (target_write_memory): Rename from write_inferior_memory. Remove old target_write_memory.
2019-08-14 17:18:21 +02:00
|| target_write_memory (mem_addr, mem_buf, mem_len) != 0)
write_enn (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
else
write_ok (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
else
{
decode_M_packet (&cs.own_buf[1], &mem_addr, &mem_len, &mem_buf);
Replace write_inferior_memory with target_write_memory target_write_memory is just a simple wrapper for write_inferior_memory. Because target_write_memory is needed for gdbsupport, and because gdb uses the name "target_write_memory" everywhere, this patch renames write_inferior_memory and removes the wrapper. I think this brings gdb and gdbserver slightly more in sync. gdb/gdbserver/ChangeLog 2019-08-15 Tom Tromey <tromey@adacore.com> * tracepoint.c (write_inferior_data_pointer) (write_inferior_integer, write_inferior_int8) (write_inferior_uinteger, m_tracepoint_action_download) (r_tracepoint_action_download, x_tracepoint_action_download) (l_tracepoint_action_download, clear_inferior_trace_buffer) (download_agent_expr, download_tracepoint_1) (download_trace_state_variables, upload_fast_traceframes): Update. * server.c (gdb_write_memory): Update. * remote-utils.c (relocate_instruction): Update. * proc-service.c (ps_pdwrite): Update. * mem-break.c (remove_memory_breakpoint) (delete_fast_tracepoint_jump, set_fast_tracepoint_jump) (uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Update. * linux-x86-low.c (append_insns) (i386_install_fast_tracepoint_jump_pad) (amd64_write_goto_address, i386_write_goto_address): Update. * linux-s390-low.c (append_insns, s390_write_goto_address): Update. * linux-ppc-low.c (ppc_relocate_instruction) (ppc_install_fast_tracepoint_jump_pad, emit_insns) (ppc_write_goto_address): Update. * linux-aarch64-low.c (append_insns): Update. * target.h (struct target_ops): Update. (write_inferior_memory): Don't declare. * target.c (target_write_memory): Rename from write_inferior_memory. Remove old target_write_memory.
2019-08-14 17:18:21 +02:00
if (target_write_memory (mem_addr, mem_buf, mem_len) == 0)
write_ok (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
else
write_enn (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
}
free (mem_buf);
if (putpkt (cs.own_buf) < 0)
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return -1;
len = getpkt (cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
if (len < 0)
return -1;
}
if (cs.own_buf[0] == 'E')
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
Remove newlines from warnings ARI pointed out that a recent patch introduced a call to "warning" with a string that ended in a newline: https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html This is generally forbidden, I believe, because warning adds its own newline. This patch removes all of the trailing newlines I was able to find. I searched for 'warning (.*\\n"' and then fixed the ones where the newline appeared at the end of the string (some had internal newlines). Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning with a newline. * guile/guile.c (handle_boot_error): Don't end warning with a newline. * cli/cli-cmds.c (exit_status_set_internal_vars): Don't end warning with a newline. * s12z-tdep.c (s12z_skip_prologue): Don't end warning with a newline. (s12z_frame_cache): Likewise. * dwarf-index-cache.c (index_cache::store): Don't end warning with a newline. * solib-svr4.c (disable_probes_interface): Don't end warning with a newline. * nat/fork-inferior.c (fork_inferior): Don't end warning with a newline. * python/python.c (do_finish_initialization): Don't end warning with a newline. gdb/gdbserver/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * remote-utils.c (look_up_one_symbol, relocate_instruction): Don't end warning with a newline. * linux-s390-low.c (s390_get_wordsize): Don't end warning with a newline. * thread-db.c (attach_thread): Don't end warning with a newline. (thread_db_notice_clone): Likewise. * tracepoint.c (gdb_agent_helper_thread): Don't end warning with a newline. * linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't end warning with a newline.
2019-06-03 16:07:29 +02:00
warning ("An error occurred while relocating an instruction: %s",
cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return -1;
}
if (!startswith (cs.own_buf, "qRelocInsn:"))
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
{
Remove newlines from warnings ARI pointed out that a recent patch introduced a call to "warning" with a string that ended in a newline: https://sourceware.org/ml/gdb-patches/2019-06/msg00000.html This is generally forbidden, I believe, because warning adds its own newline. This patch removes all of the trailing newlines I was able to find. I searched for 'warning (.*\\n"' and then fixed the ones where the newline appeared at the end of the string (some had internal newlines). Tested on x86-64 Fedora 29. gdb/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * m32c-tdep.c (m32c_m16c_address_to_pointer): Don't end warning with a newline. * guile/guile.c (handle_boot_error): Don't end warning with a newline. * cli/cli-cmds.c (exit_status_set_internal_vars): Don't end warning with a newline. * s12z-tdep.c (s12z_skip_prologue): Don't end warning with a newline. (s12z_frame_cache): Likewise. * dwarf-index-cache.c (index_cache::store): Don't end warning with a newline. * solib-svr4.c (disable_probes_interface): Don't end warning with a newline. * nat/fork-inferior.c (fork_inferior): Don't end warning with a newline. * python/python.c (do_finish_initialization): Don't end warning with a newline. gdb/gdbserver/ChangeLog 2019-06-10 Tom Tromey <tromey@adacore.com> * remote-utils.c (look_up_one_symbol, relocate_instruction): Don't end warning with a newline. * linux-s390-low.c (s390_get_wordsize): Don't end warning with a newline. * thread-db.c (attach_thread): Don't end warning with a newline. (thread_db_notice_clone): Likewise. * tracepoint.c (gdb_agent_helper_thread): Don't end warning with a newline. * linux-x86-low.c (x86_get_min_fast_tracepoint_insn_len): Don't end warning with a newline.
2019-06-03 16:07:29 +02:00
warning ("Malformed response to qRelocInsn, ignoring: %s",
cs.own_buf);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
return -1;
}
unpack_varlen_hex (cs.own_buf + strlen ("qRelocInsn:"), &written);
gdb/gdbserver/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> Stan Shebs <stan@codesourcery.com> * Makefile.in (IPA_DEPFILES, extra_libraries): New. (all): Depend on $(extra_libraries). (install-only): Install the IPA. (IPA_OBJS, IPA_LIB): New. (clean): Remove the IPA lib. (IPAGENT_CFLAGS): New. (tracepoint-ipa.o, utils-ipa.o, remote-utils-ipa.o) (regcache-ipa.o, i386-linux-ipa.o, linux-i386-ipa.o) (linux-amd64-ipa.o, amd64-linux-ipa.o): New rules. * linux-amd64-ipa.c, linux-i386-ipa.c: New files. * configure.ac: Check for atomic builtins support in the compiler. (IPA_DEPFILES, extra_libraries): Define. * configure.srv (ipa_obj): Add description. (ipa_i386_linux_regobj, ipa_amd64_linux_regobj): Define. (i[34567]86-*-linux*): Set ipa_obj. (x86_64-*-linux*): Set ipa_obj. * linux-low.c (stabilizing_threads): New. (supports_fast_tracepoints): New. (linux_detach): Stabilize threads before detaching. (handle_tracepoints): Handle internal tracing breakpoints. Assert the lwp is either not stabilizing, or is moving out of a jump pad. (linux_fast_tracepoint_collecting): New. (maybe_move_out_of_jump_pad): New. (enqueue_one_deferred_signal): New. (dequeue_one_deferred_signal): New. (linux_wait_for_event_1): If moving out of a jump pad, defer pending signals to later. (linux_stabilize_threads): New. (linux_wait_1): Check if threads need moving out of jump pads, and do it if so. (stuck_in_jump_pad_callback): New. (move_out_of_jump_pad_callback): New. (lwp_running): New. (linux_resume_one_lwp): Handle moving out of jump pads. (linux_set_resume_request): Dequeue deferred signals. (need_step_over_p): Also step over fast tracepoint jumps. (start_step_over): Also uninsert fast tracepoint jumps. (finish_step_over): Also reinsert fast tracepoint jumps. (linux_install_fast_tracepoint_jump): New. (linux_target_ops): Install linux_stabilize_threads and linux_install_fast_tracepoint_jump_pad. * linux-low.h (linux_target_ops) <get_thread_area, install_fast_tracepoint_jump_pad>: New fields. (struct lwp_info) <collecting_fast_tracepoint, pending_signals_to_report, exit_jump_pad_bkpt>: New fields. (linux_get_thread_area): Declare. * linux-x86-low.c (jump_insn): New. (x86_get_thread_area): New. (append_insns): New. (push_opcode): New. (amd64_install_fast_tracepoint_jump_pad): New. (i386_install_fast_tracepoint_jump_pad): New. (x86_install_fast_tracepoint_jump_pad): New. (the_low_target): Install x86_get_thread_area and x86_install_fast_tracepoint_jump_pad. * mem-break.c (set_raw_breakpoint_at): Use read_inferior_memory. (struct fast_tracepoint_jump): New. (fast_tracepoint_jump_insn): New. (fast_tracepoint_jump_shadow): New. (find_fast_tracepoint_jump_at): New. (fast_tracepoint_jump_here): New. (delete_fast_tracepoint_jump): New. (set_fast_tracepoint_jump): New. (uninsert_fast_tracepoint_jumps_at): New. (reinsert_fast_tracepoint_jumps_at): New. (set_breakpoint_at): Use write_inferior_memory. (uninsert_raw_breakpoint): Use write_inferior_memory. (check_mem_read): Mask out fast tracepoint jumps. (check_mem_write): Mask out fast tracepoint jumps. * mem-break.h (struct fast_tracepoint_jump): Forward declare. (set_fast_tracepoint_jump): Declare. (delete_fast_tracepoint_jump) (fast_tracepoint_jump_here, uninsert_fast_tracepoint_jumps_at) (reinsert_fast_tracepoint_jumps_at): Declare. * regcache.c: Don't compile many functions when building the in-process agent library. (init_register_cache) [IN_PROCESS_AGENT]: Don't allow allocating the register buffer in the heap. (free_register_cache): If the register buffer isn't owned by the regcache, don't free it. (set_register_cache) [IN_PROCESS_AGENT]: Don't re-alocate pre-existing register caches. * remote-utils.c (convert_int_to_ascii): Constify `from' parameter type. (convert_ascii_to_int): : Constify `from' parameter type. (decode_M_packet, decode_X_packet): Replace the `to' parameter by a `to_p' pointer to pointer parameter. If TO_P is NULL, malloc the needed buffer in-place. (relocate_instruction): New. * server.c (handle_query) <qSymbols>: If the target supports tracepoints, give it a chance of looking up symbols. Report support for fast tracepoints. (handle_status): Stabilize threads. (process_serial_event): Adjust. * server.h (struct fast_tracepoint_jump): Forward declare. (struct process_info) <fast_tracepoint_jumps>: New field. (convert_ascii_to_int, convert_int_to_ascii): Adjust. (decode_X_packet, decode_M_packet): Adjust. (relocate_instruction): Declare. (in_process_agent_loaded): Declare. (tracepoint_look_up_symbols): Declare. (struct fast_tpoint_collect_status): Declare. (fast_tracepoint_collecting): Declare. (force_unlock_trace_buffer): Declare. (handle_tracepoint_bkpts): Declare. (initialize_low_tracepoint) (supply_fast_tracepoint_registers) [IN_PROCESS_AGENT]: Declare. * target.h (struct target_ops) <stabilize_threads, install_fast_tracepoint_jump_pad>: New fields. (stabilize_threads, install_fast_tracepoint_jump_pad): New. * tracepoint.c [HAVE_MALLOC_H]: Include malloc.h. [HAVE_STDINT_H]: Include stdint.h. (trace_debug_1): Rename to ... (trace_vdebug): ... this. (trace_debug): Rename to ... (trace_debug_1): ... this. Add `level' parameter. (trace_debug): New. (ATTR_USED, ATTR_NOINLINE): New. (IP_AGENT_EXPORT): New. (gdb_tp_heap_buffer, gdb_jump_pad_buffer, gdb_jump_pad_buffer_end) (collecting, gdb_collect, stop_tracing, flush_trace_buffer) (about_to_request_buffer_space, trace_buffer_is_full) (stopping_tracepoint, expr_eval_result, error_tracepoint) (tracepoints, tracing, trace_buffer_ctrl, trace_buffer_ctrl_curr) (trace_buffer_lo, trace_buffer_hi, traceframe_read_count) (traceframe_write_count, traceframes_created) (trace_state_variables) New renaming defines. (struct ipa_sym_addresses): New. (STRINGIZE_1, STRINGIZE, IPA_SYM): New. (symbol_list): New. (ipa_sym_addrs): New. (all_tracepoint_symbols_looked_up): New. (in_process_agent_loaded): New. (write_e_ipa_not_loaded): New. (maybe_write_ipa_not_loaded): New. (tracepoint_look_up_symbols): New. (debug_threads) [IN_PROCESS_AGENT]: New. (read_inferior_memory) [IN_PROCESS_AGENT]: New. (UNKNOWN_SIDE_EFFECTS): New. (stop_tracing): New. (flush_trace_buffer): New. (stop_tracing_bkpt): New. (flush_trace_buffer_bkpt): New. (read_inferior_integer): New. (read_inferior_uinteger): New. (read_inferior_data_pointer): New. (write_inferior_data_pointer): New. (write_inferior_integer): New. (write_inferior_uinteger): New. (struct collect_static_trace_data_action): Delete. (enum tracepoint_type): New. (struct tracepoint) <type>: New field `type'. <actions_str, step_actions, step_actions_str>: Only include in GDBserver. <orig_size, obj_addr_on_target, adjusted_insn_addr> <adjusted_insn_addr_end, jump_pad, jump_pad_end>: New fields. (tracepoints): Use IP_AGENT_EXPORT. (last_tracepoint): Don't include in the IPA. (stopping_tracepoint): Use IP_AGENT_EXPORT. (trace_buffer_is_full): Use IP_AGENT_EXPORT. (alloced_trace_state_variables): New. (trace_state_variables): Use IP_AGENT_EXPORT. (traceframe_t): Delete unused variable. (circular_trace_buffer): Don't include in the IPA. (trace_buffer_start): Delete. (struct trace_buffer_control): New. (trace_buffer_free): Delete. (struct ipa_trace_buffer_control): New. (GDBSERVER_FLUSH_COUNT_MASK, GDBSERVER_FLUSH_COUNT_MASK_PREV) (GDBSERVER_FLUSH_COUNT_MASK_CURR, GDBSERVER_UPDATED_FLUSH_COUNT_BIT): New. (trace_buffer_ctrl): New. (TRACE_BUFFER_CTRL_CURR): New. (trace_buffer_start, trace_buffer_free, trace_buffer_end_free): Reimplement as macros. (trace_buffer_wrap): Delete. (traceframe_write_count, traceframe_read_count) (traceframes_created, tracing): Use IP_AGENT_EXPORT. (struct tracepoint_hit_ctx) <type>: New field. (struct fast_tracepoint_ctx): New. (memory_barrier): New. (cmpxchg): New. (record_tracepoint_error): Update atomically in the IPA. (clear_inferior_trace_buffer): New. (about_to_request_buffer_space): New. (trace_buffer_alloc): Handle GDBserver and inferior simulatenous updating the same buffer. (add_tracepoint): Default the tracepoint's type to trap tracepoint, and orig_size to -1. (get_trace_state_variable) [IN_PROCESS_AGENT]: Handle allocated internal variables. (create_trace_state_variable): New parameter `gdb'. Handle it. (clear_installed_tracepoints): Clear fast tracepoint jumps. (cmd_qtdp): Handle fast tracepoints. (cmd_qtdv): Adjust. (max_jump_pad_size): New. (gdb_jump_pad_head): New. (get_jump_space_head): New. (claim_jump_space): New. (sort_tracepoints): New. (MAX_JUMP_SIZE): New. (cmd_qtstart): Handle fast tracepoints. Sync tracepoints with the IPA. (stop_tracing) [IN_PROCESS_AGENT]: Don't include the tdisconnected support. Upload fast traceframes, and delete internal IPA breakpoints. (stop_tracing_handler): New. (flush_trace_buffer_handler): New. (cmd_qtstop): Upload fast tracepoints. (response_tracepoint): Handle fast tracepoints. (tracepoint_finished_step): Upload fast traceframes. Set the tracepoint hit context's tracepoint type. (handle_tracepoint_bkpts): New. (tracepoint_was_hit): Set the tracepoint hit context's tracepoint type. Add comment about fast tracepoints. (collect_data_at_tracepoint) [IN_PROCESS_AGENT]: Don't access the non-existing action_str field. (get_context_regcache): Handle fast tracepoints. (do_action_at_tracepoint) [!IN_PROCESS_AGENT]: Don't write the PC to the regcache. (fast_tracepoint_from_jump_pad_address): New. (fast_tracepoint_from_ipa_tpoint_address): New. (collecting_t): New. (force_unlock_trace_buffer): New. (fast_tracepoint_collecting): New. (collecting): New. (gdb_collect): New. (write_inferior_data_ptr): New. (target_tp_heap): New. (target_malloc): New. (download_agent_expr): New. (UALIGN): New. (download_tracepoints): New. (download_trace_state_variables): New. (upload_fast_traceframes): New. (IPA_FIRST_TRACEFRAME): New. (IPA_NEXT_TRACEFRAME_1): New. (IPA_NEXT_TRACEFRAME): New. [IN_PROCESS_AGENT]: Include sys/mman.h and fcntl.h. [IN_PROCESS_AGENT] (gdb_tp_heap_buffer, gdb_jump_pad_buffer) (gdb_jump_pad_buffer_end): New. [IN_PROCESS_AGENT] (initialize_tracepoint_ftlib): New. (initialize_tracepoint): Adjust. [IN_PROCESS_AGENT]: Allocate the IPA heap, and jump pad scratch buffer. Initialize the low module. * utils.c (PREFIX, TOOLNAME): New. (malloc_failure): Use PREFIX. (error): In the IPA, an error causes an exit. (fatal, warning): Use PREFIX. (internal_error): Use TOOLNAME. (NUMCELLS): Increase to 10. * configure, config.in: Regenerate. gdb/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * NEWS: Mention gdbserver fast tracepoints support. gdb/doc/ 2010-06-01 Pedro Alves <pedro@codesourcery.com> * gdb.texinfo (Set Tracepoints): Mention tracepoints support in gdbserver, and add cross reference. (Tracepoints support in gdbserver): New subsection.
2010-06-01 15:20:52 +02:00
*to += written;
return 0;
}
void
monitor_output (const char *msg)
{
int len = strlen (msg);
Add casts to memory allocation related calls Most allocation functions (if not all) return a void* pointing to the allocated memory. In C++, we need to add an explicit cast when assigning the result to a pointer to another type (which is the case more often than not). The content of this patch is taken from Pedro's branch, from commit "(mostly) auto-generated patch to insert casts needed for C++". I validated that the changes make sense and manually reflowed the code to make it respect the coding style. I also found multiple places where I could use XNEW/XNEWVEC/XRESIZEVEC/etc. Thanks a lot to whoever did that automated script to insert casts, doing it completely by hand would have taken a ridiculous amount of time. Only files built on x86 with --enable-targets=all are modified. This means that all other -nat.c files are untouched and will have to be dealt with later by using appropiate compilers. Or maybe we can try to build them with a regular g++ just to know where to add casts, I don't know. I built-tested this with --enable-targets=all and reg-tested. Here's the changelog entry, which was not too bad to make despite the size, thanks to David Malcom's script. I fixed some bits by hand, but there might be some wrong parts left (hopefully not). gdb/ChangeLog: * aarch64-linux-tdep.c (aarch64_stap_parse_special_token): Add cast to allocation result assignment. * ada-exp.y (write_object_renaming): Likewise. (write_ambiguous_var): Likewise. (ada_nget_field_index): Likewise. (write_var_or_type): Likewise. * ada-lang.c (ada_decode_symbol): Likewise. (ada_value_assign): Likewise. (value_pointer): Likewise. (cache_symbol): Likewise. (add_nonlocal_symbols): Likewise. (ada_name_for_lookup): Likewise. (symbol_completion_add): Likewise. (ada_to_fixed_type_1): Likewise. (ada_get_next_arg): Likewise. (defns_collected): Likewise. * ada-lex.l (processId): Likewise. (processString): Likewise. * ada-tasks.c (read_known_tasks_array): Likewise. (read_known_tasks_list): Likewise. * ada-typeprint.c (decoded_type_name): Likewise. * addrmap.c (addrmap_mutable_create_fixed): Likewise. * amd64-tdep.c (amd64_push_arguments): Likewise. (amd64_displaced_step_copy_insn): Likewise. (amd64_classify_insn_at): Likewise. (amd64_relocate_instruction): Likewise. * amd64obsd-tdep.c (amd64obsd_sigtramp_p): Likewise. * arch-utils.c (simple_displaced_step_copy_insn): Likewise. (initialize_current_architecture): Likewise. * arm-linux-tdep.c (arm_stap_parse_special_token): Likewise. * arm-symbian-tdep.c (arm_symbian_osabi_sniffer): Likewise. * arm-tdep.c (arm_exidx_new_objfile): Likewise. (arm_push_dummy_call): Likewise. (extend_buffer_earlier): Likewise. (arm_adjust_breakpoint_address): Likewise. (arm_skip_stub): Likewise. * auto-load.c (filename_is_in_pattern): Likewise. (maybe_add_script_file): Likewise. (maybe_add_script_text): Likewise. (auto_load_objfile_script_1): Likewise. * auxv.c (ld_so_xfer_auxv): Likewise. * ax-general.c (new_agent_expr): Likewise. (grow_expr): Likewise. (ax_reg_mask): Likewise. * bcache.c (bcache_full): Likewise. * breakpoint.c (program_breakpoint_here_p): Likewise. * btrace.c (parse_xml_raw): Likewise. * build-id.c (build_id_to_debug_bfd): Likewise. * buildsym.c (end_symtab_with_blockvector): Likewise. * c-exp.y (string_exp): Likewise. (qualified_name): Likewise. (write_destructor_name): Likewise. (operator_stoken): Likewise. (parse_number): Likewise. (scan_macro_expansion): Likewise. (yylex): Likewise. (c_print_token): Likewise. * c-lang.c (c_get_string): Likewise. (emit_numeric_character): Likewise. * charset.c (wchar_iterate): Likewise. * cli/cli-cmds.c (complete_command): Likewise. (make_command): Likewise. * cli/cli-dump.c (restore_section_callback): Likewise. (restore_binary_file): Likewise. * cli/cli-interp.c (cli_interpreter_exec): Likewise. * cli/cli-script.c (execute_control_command): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (add_pe_forwarded_sym): Likewise. (read_pe_exported_syms): Likewise. * coffread.c (coff_read_struct_type): Likewise. (coff_read_enum_type): Likewise. * common/btrace-common.c (btrace_data_append): Likewise. * common/buffer.c (buffer_grow): Likewise. * common/filestuff.c (gdb_fopen_cloexec): Likewise. * common/format.c (parse_format_string): Likewise. * common/gdb_vecs.c (delim_string_to_char_ptr_vec_append): Likewise. * common/xml-utils.c (xml_escape_text): Likewise. * compile/compile-object-load.c (copy_sections): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * completer.c (filename_completer): Likewise. * corefile.c (read_memory_typed_address): Likewise. (write_memory_unsigned_integer): Likewise. (write_memory_signed_integer): Likewise. (complete_set_gnutarget): Likewise. * corelow.c (get_core_register_section): Likewise. * cp-name-parser.y (d_grab): Likewise. (allocate_info): Likewise. (cp_new_demangle_parse_info): Likewise. * cp-namespace.c (cp_scan_for_anonymous_namespaces): Likewise. (cp_lookup_symbol_in_namespace): Likewise. (lookup_namespace_scope): Likewise. (find_symbol_in_baseclass): Likewise. (cp_lookup_nested_symbol): Likewise. (cp_lookup_transparent_type_loop): Likewise. * cp-support.c (copy_string_to_obstack): Likewise. (make_symbol_overload_list): Likewise. (make_symbol_overload_list_namespace): Likewise. (make_symbol_overload_list_adl_namespace): Likewise. (first_component_command): Likewise. * cp-valprint.c (cp_print_value): Likewise. * ctf.c (ctf_xfer_partial): Likewise. * d-exp.y (StringExp): Likewise. * d-namespace.c (d_lookup_symbol_in_module): Likewise. (lookup_module_scope): Likewise. (find_symbol_in_baseclass): Likewise. (d_lookup_nested_symbol): Likewise. * dbxread.c (find_stab_function_addr): Likewise. (read_dbx_symtab): Likewise. (dbx_end_psymtab): Likewise. (cp_set_block_scope): Likewise. * dcache.c (dcache_alloc): Likewise. * demangle.c (_initialize_demangler): Likewise. * dicos-tdep.c (dicos_load_module_p): Likewise. * dictionary.c (dict_create_hashed_expandable): Likewise. (dict_create_linear_expandable): Likewise. (expand_hashtable): Likewise. (add_symbol_linear_expandable): Likewise. * dwarf2-frame.c (add_cie): Likewise. (add_fde): Likewise. (dwarf2_build_frame_info): Likewise. * dwarf2expr.c (dwarf_expr_grow_stack): Likewise. (dwarf_expr_fetch_address): Likewise. (add_piece): Likewise. (execute_stack_op): Likewise. * dwarf2loc.c (chain_candidate): Likewise. (dwarf_entry_parameter_to_value): Likewise. (read_pieced_value): Likewise. (write_pieced_value): Likewise. * dwarf2read.c (dwarf2_read_section): Likewise. (add_type_unit): Likewise. (read_comp_units_from_section): Likewise. (fixup_go_packaging): Likewise. (dwarf2_compute_name): Likewise. (dwarf2_physname): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (read_call_site_scope): Likewise. (dwarf2_attach_fields_to_type): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (read_common_block): Likewise. (abbrev_table_read_table): Likewise. (guess_partial_die_structure_name): Likewise. (fixup_partial_die): Likewise. (add_file_name): Likewise. (dwarf2_const_value_data): Likewise. (dwarf2_const_value_attr): Likewise. (build_error_marker_type): Likewise. (guess_full_die_structure_name): Likewise. (anonymous_struct_prefix): Likewise. (typename_concat): Likewise. (dwarf2_canonicalize_name): Likewise. (dwarf2_name): Likewise. (write_constant_as_bytes): Likewise. (dwarf2_fetch_constant_bytes): Likewise. (copy_string): Likewise. (parse_macro_definition): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_rel_plt_read): Likewise. (elf_gnu_ifunc_resolve_by_cache): Likewise. (elf_gnu_ifunc_resolve_by_got): Likewise. (elf_read_minimal_symbols): Likewise. (elf_gnu_ifunc_record_cache): Likewise. * event-top.c (top_level_prompt): Likewise. (command_line_handler): Likewise. * exec.c (resize_section_table): Likewise. * expprint.c (print_subexp_standard): Likewise. * fbsd-tdep.c (fbsd_collect_regset_section_cb): Likewise. * findcmd.c (parse_find_args): Likewise. * findvar.c (address_from_register): Likewise. * frame.c (get_prev_frame_always): Likewise. * gdb_bfd.c (gdb_bfd_ref): Likewise. (get_section_descriptor): Likewise. * gdb_obstack.c (obconcat): Likewise. (obstack_strdup): Likewise. * gdbtypes.c (lookup_function_type_with_arguments): Likewise. (create_set_type): Likewise. (lookup_unsigned_typename): Likewise. (lookup_signed_typename): Likewise. (resolve_dynamic_union): Likewise. (resolve_dynamic_struct): Likewise. (add_dyn_prop): Likewise. (copy_dynamic_prop_list): Likewise. (arch_flags_type): Likewise. (append_composite_type_field_raw): Likewise. * gdbtypes.h (INIT_FUNC_SPECIFIC): Likewise. * gnu-v3-abi.c (gnuv3_rtti_type): Likewise. * go-exp.y (string_exp): Likewise. * go-lang.c (go_demangle): Likewise. * guile/guile.c (compute_scheme_string): Likewise. * guile/scm-cmd.c (gdbscm_parse_command_name): Likewise. (gdbscm_canonicalize_command_name): Likewise. * guile/scm-ports.c (ioscm_init_stdio_buffers): Likewise. (ioscm_init_memory_port): Likewise. (ioscm_reinit_memory_port): Likewise. * guile/scm-utils.c (gdbscm_gc_xstrdup): Likewise. (gdbscm_gc_dup_argv): Likewise. * h8300-tdep.c (h8300_push_dummy_call): Likewise. * hppa-tdep.c (internalize_unwinds): Likewise. (read_unwind_info): Likewise. * i386-cygwin-tdep.c (core_process_module_section): Likewise. (windows_core_xfer_shared_libraries): Likewise. * i386-tdep.c (i386_displaced_step_copy_insn): Likewise. (i386_stap_parse_special_token_triplet): Likewise. (i386_stap_parse_special_token_three_arg_disp): Likewise. * i386obsd-tdep.c (i386obsd_sigtramp_p): Likewise. * inf-child.c (inf_child_fileio_readlink): Likewise. * inf-ptrace.c (inf_ptrace_fetch_register): Likewise. (inf_ptrace_store_register): Likewise. * infrun.c (follow_exec): Likewise. (displaced_step_prepare_throw): Likewise. (save_stop_context): Likewise. (save_infcall_suspend_state): Likewise. * jit.c (jit_read_descriptor): Likewise. (jit_read_code_entry): Likewise. (jit_symtab_line_mapping_add_impl): Likewise. (finalize_symtab): Likewise. (jit_unwind_reg_get_impl): Likewise. * jv-exp.y (QualifiedName): Likewise. * jv-lang.c (get_java_utf8_name): Likewise. (type_from_class): Likewise. (java_demangle_type_signature): Likewise. (java_class_name_from_physname): Likewise. * jv-typeprint.c (java_type_print_base): Likewise. * jv-valprint.c (java_value_print): Likewise. * language.c (add_language): Likewise. * linespec.c (add_sal_to_sals_basic): Likewise. (add_sal_to_sals): Likewise. (decode_objc): Likewise. (find_linespec_symbols): Likewise. * linux-fork.c (fork_save_infrun_state): Likewise. * linux-nat.c (linux_nat_detach): Likewise. (linux_nat_fileio_readlink): Likewise. * linux-record.c (record_linux_sockaddr): Likewise. (record_linux_msghdr): Likewise. (Do): Likewise. * linux-tdep.c (linux_core_info_proc_mappings): Likewise. (linux_collect_regset_section_cb): Likewise. (linux_get_siginfo_data): Likewise. * linux-thread-db.c (try_thread_db_load_from_pdir_1): Likewise. (try_thread_db_load_from_dir): Likewise. (thread_db_load_search): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_m16c_address_to_pointer): Likewise. (m32c_m16c_pointer_to_address): Likewise. * m68hc11-tdep.c (m68hc11_pseudo_register_write): Likewise. * m68k-tdep.c (m68k_get_longjmp_target): Likewise. * machoread.c (macho_check_dsym): Likewise. * macroexp.c (resize_buffer): Likewise. (gather_arguments): Likewise. (maybe_expand): Likewise. * macrotab.c (new_macro_key): Likewise. (new_source_file): Likewise. (new_macro_definition): Likewise. * mdebugread.c (parse_symbol): Likewise. (parse_type): Likewise. (parse_partial_symbols): Likewise. (psymtab_to_symtab_1): Likewise. * mem-break.c (default_memory_insert_breakpoint): Likewise. * mi/mi-cmd-break.c (mi_argv_to_format): Likewise. * mi/mi-main.c (mi_cmd_data_read_memory): Likewise. (mi_cmd_data_read_memory_bytes): Likewise. (mi_cmd_data_write_memory_bytes): Likewise. (mi_cmd_trace_frame_collected): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. (mi_parse): Likewise. * minidebug.c (lzma_open): Likewise. (lzma_pread): Likewise. * mips-tdep.c (mips_read_fp_register_single): Likewise. (mips_print_fp_register): Likewise. * mipsnbsd-tdep.c (mipsnbsd_get_longjmp_target): Likewise. * mipsread.c (read_alphacoff_dynamic_symtab): Likewise. * mt-tdep.c (mt_register_name): Likewise. (mt_registers_info): Likewise. (mt_push_dummy_call): Likewise. * namespace.c (add_using_directive): Likewise. * nat/linux-btrace.c (perf_event_read): Likewise. (linux_enable_bts): Likewise. * nat/linux-osdata.c (linux_common_core_of_thread): Likewise. * nat/linux-ptrace.c (linux_ptrace_test_ret_to_nx): Likewise. * nto-tdep.c (nto_find_and_open_solib): Likewise. (nto_parse_redirection): Likewise. * objc-lang.c (objc_demangle): Likewise. (find_methods): Likewise. * objfiles.c (get_objfile_bfd_data): Likewise. (set_objfile_main_name): Likewise. (allocate_objfile): Likewise. (objfile_relocate): Likewise. (update_section_map): Likewise. * osabi.c (generic_elf_osabi_sniff_abi_tag_sections): Likewise. * p-exp.y (exp): Likewise. (yylex): Likewise. * p-valprint.c (pascal_object_print_value): Likewise. * parse.c (initialize_expout): Likewise. (mark_completion_tag): Likewise. (copy_name): Likewise. (parse_float): Likewise. (type_stack_reserve): Likewise. * ppc-linux-tdep.c (ppc_stap_parse_special_token): Likewise. (ppu2spu_prev_register): Likewise. * ppc-ravenscar-thread.c (supply_register_at_address): Likewise. * printcmd.c (printf_wide_c_string): Likewise. (printf_pointer): Likewise. * probe.c (parse_probes): Likewise. * python/py-cmd.c (gdbpy_parse_command_name): Likewise. (cmdpy_init): Likewise. * python/py-gdb-readline.c (gdbpy_readline_wrapper): Likewise. * python/py-symtab.c (set_sal): Likewise. * python/py-unwind.c (pyuw_sniffer): Likewise. * python/python.c (python_interactive_command): Likewise. (compute_python_string): Likewise. * ravenscar-thread.c (get_running_thread_id): Likewise. * record-full.c (record_full_exec_insn): Likewise. (record_full_core_open_1): Likewise. * regcache.c (regcache_raw_read_signed): Likewise. (regcache_raw_read_unsigned): Likewise. (regcache_cooked_read_signed): Likewise. (regcache_cooked_read_unsigned): Likewise. * remote-fileio.c (remote_fileio_func_open): Likewise. (remote_fileio_func_rename): Likewise. (remote_fileio_func_unlink): Likewise. (remote_fileio_func_stat): Likewise. (remote_fileio_func_system): Likewise. * remote-mips.c (mips_xfer_memory): Likewise. (mips_load_srec): Likewise. (pmon_end_download): Likewise. * remote.c (new_remote_state): Likewise. (map_regcache_remote_table): Likewise. (remote_register_number_and_offset): Likewise. (init_remote_state): Likewise. (get_memory_packet_size): Likewise. (remote_pass_signals): Likewise. (remote_program_signals): Likewise. (remote_start_remote): Likewise. (remote_check_symbols): Likewise. (remote_query_supported): Likewise. (extended_remote_attach): Likewise. (process_g_packet): Likewise. (store_registers_using_G): Likewise. (putpkt_binary): Likewise. (read_frame): Likewise. (compare_sections_command): Likewise. (remote_hostio_pread): Likewise. (remote_hostio_readlink): Likewise. (remote_file_put): Likewise. (remote_file_get): Likewise. (remote_pid_to_exec_file): Likewise. (_initialize_remote): Likewise. * rs6000-aix-tdep.c (rs6000_aix_ld_info_to_xml): Likewise. (rs6000_aix_core_xfer_shared_libraries_aix): Likewise. * rs6000-tdep.c (ppc_displaced_step_copy_insn): Likewise. (bfd_uses_spe_extensions): Likewise. * s390-linux-tdep.c (s390_displaced_step_copy_insn): Likewise. * score-tdep.c (score7_malloc_and_get_memblock): Likewise. * solib-dsbt.c (decode_loadmap): Likewise. (fetch_loadmap): Likewise. (scan_dyntag): Likewise. (enable_break): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (fetch_loadmap): Likewise. (enable_break2): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_relocate_main_executable): Likewise. (spu_bfd_open): Likewise. * solib-svr4.c (lm_info_read): Likewise. (read_program_header): Likewise. (find_program_interpreter): Likewise. (scan_dyntag): Likewise. (elf_locate_base): Likewise. (open_symbol_file_object): Likewise. (read_program_headers_from_bfd): Likewise. (svr4_relocate_main_executable): Likewise. * solib-target.c (solib_target_relocate_section_addresses): Likewise. * solib.c (solib_find_1): Likewise. (exec_file_find): Likewise. (solib_find): Likewise. * source.c (openp): Likewise. (print_source_lines_base): Likewise. (forward_search_command): Likewise. * sparc-ravenscar-thread.c (supply_register_at_address): Likewise. * spu-tdep.c (spu2ppu_prev_register): Likewise. (spu_get_overlay_table): Likewise. * stabsread.c (patch_block_stabs): Likewise. (define_symbol): Likewise. (again:): Likewise. (read_member_functions): Likewise. (read_one_struct_field): Likewise. (read_enum_type): Likewise. (common_block_start): Likewise. * stack.c (read_frame_arg): Likewise. (backtrace_command): Likewise. * stap-probe.c (stap_parse_register_operand): Likewise. * symfile.c (syms_from_objfile_1): Likewise. (find_separate_debug_file): Likewise. (load_command): Likewise. (load_progress): Likewise. (load_section_callback): Likewise. (reread_symbols): Likewise. (add_filename_language): Likewise. (allocate_compunit_symtab): Likewise. (read_target_long_array): Likewise. (simple_read_overlay_table): Likewise. * symtab.c (symbol_set_names): Likewise. (resize_symbol_cache): Likewise. (rbreak_command): Likewise. (completion_list_add_name): Likewise. (completion_list_objc_symbol): Likewise. (add_filename_to_list): Likewise. * target-descriptions.c (maint_print_c_tdesc_cmd): Likewise. * target-memory.c (target_write_memory_blocks): Likewise. * target.c (target_read_string): Likewise. (read_whatever_is_readable): Likewise. (target_read_alloc_1): Likewise. (simple_search_memory): Likewise. (target_fileio_read_alloc_1): Likewise. * tilegx-tdep.c (tilegx_push_dummy_call): Likewise. * top.c (command_line_input): Likewise. * tracefile-tfile.c (tfile_fetch_registers): Likewise. * tracefile.c (tracefile_fetch_registers): Likewise. * tracepoint.c (add_memrange): Likewise. (init_collection_list): Likewise. (add_aexpr): Likewise. (trace_dump_actions): Likewise. (parse_trace_status): Likewise. (parse_tracepoint_definition): Likewise. (parse_tsv_definition): Likewise. (parse_static_tracepoint_marker_definition): Likewise. * tui/tui-file.c (tui_sfileopen): Likewise. (tui_file_adjust_strbuf): Likewise. * tui/tui-io.c (tui_expand_tabs): Likewise. * tui/tui-source.c (tui_set_source_content): Likewise. * typeprint.c (find_global_typedef): Likewise. * ui-file.c (do_ui_file_xstrdup): Likewise. (ui_file_obsavestring): Likewise. (mem_file_write): Likewise. * utils.c (make_hex_string): Likewise. (get_regcomp_error): Likewise. (puts_filtered_tabular): Likewise. (gdb_realpath_keepfile): Likewise. (ldirname): Likewise. (gdb_bfd_errmsg): Likewise. (substitute_path_component): Likewise. * valops.c (search_struct_method): Likewise. (find_oload_champ_namespace_loop): Likewise. * valprint.c (print_decimal_chars): Likewise. (read_string): Likewise. (generic_emit_char): Likewise. * varobj.c (varobj_delete): Likewise. (varobj_value_get_print_value): Likewise. * vaxobsd-tdep.c (vaxobsd_sigtramp_sniffer): Likewise. * windows-tdep.c (display_one_tib): Likewise. * xcoffread.c (read_xcoff_symtab): Likewise. (process_xcoff_symbol): Likewise. (swap_sym): Likewise. (scan_xcoff_symtab): Likewise. (xcoff_initial_scan): Likewise. * xml-support.c (gdb_xml_end_element): Likewise. (xml_process_xincludes): Likewise. (xml_fetch_content_from_file): Likewise. * xml-syscall.c (xml_list_of_syscalls): Likewise. * xstormy16-tdep.c (xstormy16_push_dummy_call): Likewise. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Add cast to allocation result assignment. (gdb_unparse_agent_expr): Likewise. * hostio.c (require_data): Likewise. (handle_pread): Likewise. * linux-low.c (disable_regset): Likewise. (fetch_register): Likewise. (store_register): Likewise. (get_dynamic): Likewise. (linux_qxfer_libraries_svr4): Likewise. * mem-break.c (delete_fast_tracepoint_jump): Likewise. (set_fast_tracepoint_jump): Likewise. (uninsert_fast_tracepoint_jumps_at): Likewise. (reinsert_fast_tracepoint_jumps_at): Likewise. (validate_inserted_breakpoint): Likewise. (clone_agent_expr): Likewise. * regcache.c (init_register_cache): Likewise. * remote-utils.c (putpkt_binary_1): Likewise. (decode_M_packet): Likewise. (decode_X_packet): Likewise. (look_up_one_symbol): Likewise. (relocate_instruction): Likewise. (monitor_output): Likewise. * server.c (handle_search_memory): Likewise. (handle_qxfer_exec_file): Likewise. (handle_qxfer_libraries): Likewise. (handle_qxfer): Likewise. (handle_query): Likewise. (handle_v_cont): Likewise. (handle_v_run): Likewise. (captured_main): Likewise. * target.c (write_inferior_memory): Likewise. * thread-db.c (try_thread_db_load_from_dir): Likewise. * tracepoint.c (init_trace_buffer): Likewise. (add_tracepoint_action): Likewise. (add_traceframe): Likewise. (add_traceframe_block): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtdv): Likewise. (cmd_qtstatus): Likewise. (response_source): Likewise. (response_tsv): Likewise. (cmd_qtnotes): Likewise. (gdb_collect): Likewise. (initialize_tracepoint): Likewise.
2015-09-25 20:08:06 +02:00
char *buf = (char *) xmalloc (len * 2 + 2);
buf[0] = 'O';
bin2hex ((const gdb_byte *) msg, buf + 1, len);
putpkt (buf);
free (buf);
}
2007-07-17 Pedro Alves <pedro_alves@portugalmail.pt> Daniel Jacobowitz <dan@codesourcery.com> * config/i386/cygwin.mt (TDEPFILES): Add solib-target.o. * coff-pe-read.c (read_pe_exported_syms): Delete verbose printf. * NEWS: Mention gdbserver DLL support. * gdb.base/unload.c (dlopen, dlsym, dlclose, dlerror): Define for __WIN32__. (SHLIB_NAME): Delete definition. Always pass dlerror to fprintf. * gdb.base/unload.exp: Use shared library test routines. * inferiors.c (all_dlls, dlls_changed, get_dll): New. (add_thread): Minor cleanups. (clear_inferiors): Move lower in the file. Clear the DLL list. (free_one_dll, match_dll, loaded_dll, unloaded_dll, clear_list): New. * remote-utils.c (prepare_resume_reply): Check dlls_changed. (xml_escape_text): New. * server.c (handle_query): Handle qXfer:libraries:read. Report it for qSupported. (handle_v_cont): Report errors. (gdbserver_version): Update. (main): Correct size of own_buf. Do not report initial DLL events. * server.h (struct dll_info, all_dlls, dlls_changed, loaded_dll) (unloaded_dll, xml_escape_text): New. * win32-low.c (enum target_waitkind): Update comments. (win32_add_one_solib, get_image_name, winapi_EnumProcessModules) (winapi_GetModuleInformation, winapi_GetModuleFileNameExA) (win32_EnumProcessModules, win32_GetModuleInformation) (win32_GetModuleFileNameExA, load_psapi, psapi_get_dll_name) (winapi_CreateToolhelp32Snapshot, winapi_Module32First) (winapi_Module32Next, win32_CreateToolhelp32Snapshot) (win32_Module32First, win32_Module32Next, load_toolhelp) (toolhelp_get_dll_name, handle_load_dll, handle_unload_dll): New. (get_child_debug_event): Handle DLL events. (win32_wait): Likewise.
2007-07-17 14:51:41 +02:00
Static tracepoints support, and UST integration. gdb/gdbserver/ * configure.ac: Handle --with-ust. substitute ustlibs and ustinc. * mem-break.c (uninsert_all_breakpoints) (reinsert_all_breakpoints): New. * mem-break.h (reinsert_all_breakpoints, uninsert_all_breakpoints): * tracepoint.c (ust_loaded, helper_thread_id, cmd_buf): New. (gdb_agent_ust_loaded, helper_thread_id) (gdb_agent_helper_thread_id): New macros. (struct ipa_sym_addresses): Add addr_ust_loaded, addr_helper_thread_id, addr_cmd_buf. (symbol_list): Add ust_loaded, helper_thread_id, cmd_buf. (in_process_agent_loaded_ust): New. (write_e_ust_not_loaded): New. (maybe_write_ipa_ust_not_loaded): New. (struct collect_static_trace_data_action): New. (enum tracepoint_type) <static_tracepoint>: New. (struct tracepoint) <handle>: Mention static tracepoints. (struct static_tracepoint_ctx): New. (CMD_BUF_SIZE): New. (add_tracepoint_action): Handle static tracepoint actions. (unprobe_marker_at): New. (clear_installed_tracepoints): Handle static tracepoints. (cmd_qtdp): Handle static tracepoints. (probe_marker_at): New. (cmd_qtstart): Handle static tracepoints. (response_tracepoint): Handle static tracepoints. (cmd_qtfstm, cmd_qtsstm, cmd_qtstmat): New. (handle_tracepoint_query): Handle qTfSTM, qTsSTM and qTSTMat. (get_context_regcache): Handle static tracepoints. (do_action_at_tracepoint): Handle static tracepoint actions. (traceframe_find_block_type): Handle static trace data blocks. (traceframe_read_sdata): New. (download_tracepoints): Download static tracepoint actions. [HAVE_UST] Include ust/ust.h, dlfcn.h, sys/socket.h, and sys/un.h. (GDB_PROBE_NAME): New. (ust_ops): New. (GET_UST_SYM): New. (USTF): New. (dlsym_ust): New. (ust_marker_to_static_tracepoint): New. (gdb_probe): New. (collect_ust_data_at_tracepoint): New. (gdb_ust_probe): New. (UNIX_PATH_MAX, SOCK_DIR): New. (gdb_ust_connect_sync_socket): New. (resume_thread, stop_thread): New. (run_inferior_command): New. (init_named_socket): New. (gdb_ust_socket_init): New. (cstr_to_hexstr): New. (next_st): New. (first_marker, next_marker): New. (response_ust_marker): New. (cmd_qtfstm, cmd_qtsstm): New. (unprobe_marker_at, probe_marker_at): New. (cmd_qtstmat, gdb_ust_thread): New. (gdb_ust_init): New. (initialize_tracepoint_ftlib): Call gdb_ust_init. * linux-amd64-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (x86_64_st_collect_regmap): New. (X86_64_NUM_ST_COLLECT_GREGS): New. (AMD64_RIP_REGNUM): New. (supply_static_tracepoint_registers): New. * linux-i386-ipa.c [HAVE_UST]: Include ust/processor.h (ST_REGENTRY): New. (i386_st_collect_regmap): New. (i386_NUM_ST_COLLECT_GREGS): New. (supply_static_tracepoint_registers): New. * server.c (handle_query): Handle qXfer:statictrace:read. <qSupported>: Report support for StaticTracepoints, and qXfer:statictrace:read features. * server.h (traceframe_read_sdata) (supply_static_tracepoint_registers): Declare. * remote-utils.c (convert_int_to_ascii, hexchars, ishex, tohex) (unpack_varlen_hex): Include in IPA build. * Makefile.in (ustlibs, ustinc): New. (IPA_OBJS): Add remote-utils-ipa.o. ($(IPA_LIB)): Link -ldl and -lpthread. (UST_CFLAGS): New. (IPAGENT_CFLAGS): Add UST_CFLAGS. * config.in, configure: Regenerate. gdb/ * NEWS: Mention new support for static tracepoints. (New packets): Mention qTfSTM, qTsSTM, qTSTMat and qXfer:statictrace:read. (New features in the GDB remote stub, GDBserver): Mention static tracepoints support using an UST based backend. (New commands): Mention "info static-tracepoint-markers" and "strace". * breakpoint.c (is_marker_spec): New. (is_tracepoint): Handle static tracepoints. (validate_commands_for_breakpoint): Static tracepoints can't do while-stepping. (static_tracepoints_here): New. (bpstat_what): Handle static tracepoints. (print_one_breakpoint_location, allocate_bp_location, mention): Ditto. (create_breakpoint_sal): Ditto. (decode_static_tracepoint_spec): New. (create_breakpoint): Replace `hardwareflag', and `traceflag' with `type_wanted'. Adjust. Handle static tracepoint marker locations. (break_command_1): Adjust. (update_static_tracepoint): New. (update_breakpoint_locations): Handle static tracepoints. (breakpoint_re_set_one): Handle static tracepoint marker locations. (disable_command, enable_command): Handle static tracepoints. (trace_command, ftrace_command): Adjust. (strace_command): New. (create_tracepoint_from_upload): Adjust. (save_breakpoints): Handle static tracepoints. (_initialize_breakpoint): Install the "strace" command. * breakpoint.h (enum bptype): New bp_static_tracepoint type. (struct breakpoint): New fields static_trace_marker_id and static_trace_marker_id_idx. (breakpoints_here_p): Declare. (create_breakpoint): Adjust. (static_tracepoints_here): Declare. * remote.c (struct remote_state) <static_tracepoints>: New field. (PACKET_qXfer_statictrace_read, PACKET_StaticTracepoints): New. (remote_static_tracepoint_marker_at): New. (remote_static_tracepoint_markers_by_strid): New. (remote_static_tracepoint_feature): New. (remote_disconnected_tracing_feature): Handle "StaticTracepoints". (remote_xfer_partial): Handle TARGET_OBJECT_STATIC_TRACE_DATA. (remote_supports_static_tracepoints): New. (remote_download_tracepoint): Download static tracepoints. (init_remote_ops): Install remote_static_tracepoint_marker_at and remote_static_tracepoint_markers_by_strid. (_initialize_remote): Install set|show remote static-tracepoints, and set|show remote read-sdata-object commands. * target.c (update_current_target): Inherit and default to_static_tracepoint_marker_at, and to_static_tracepoint_markers_by_strid. * target.h (static_tracepoint_marker): Forward declare. (enum target_object): New object TARGET_OBJECT_STATIC_TRACE_DATA. (static_tracepoint_marker_p): New typedef. (DEF_VEC_P(static_tracepoint_marker_p)): New VEC type. (struct target_ops): New fields to_static_tracepoint_marker_at and to_static_tracepoint_markers_by_strid. (target_static_tracepoint_marker_at) (target_static_tracepoint_markers_by_strid): New. * tracepoint.c: Include source.h. (validate_actionline): Handle $_sdata. (struct collection_list): New field strace_data. (add_static_trace_data): New. (clear_collection_list): Clear strace_data. (stringify_collection_list): Account for a possible static trace data collection. (encode_actions_1): Encode an $_sdata collection. (parse_tracepoint_definition): Handle static tracepoints. (parse_static_tracepoint_marker_definition): New. (release_static_tracepoint_marker): New. (print_one_static_tracepoint_marker): New. (info_static_tracepoint_markers_command): New. (sdata_make_value): New. (_initialize_tracepoint): Create the $_sdata convenience variable. Add the "info static-tracepoint-markers" command. Mention $_sdata in the "collect" command's help output. * tracepoint.h (struct static_tracepoint_marker): New. (parse_static_tracepoint_marker_definition) (release_static_tracepoint_marker): Declare. * mi/mi-cmd-break.c (mi_cmd_break_insert): Adjust. * python/py-breakpoint.c (bppy_new): Adjust. doc/ * gdb.texinfo (Convenience Variables): Document $_sdata. (Commands to Set Tracepoints): Describe static tracepoints. Add `Listing Static Tracepoint Markers' menu entry. Document "strace". (Tracepoint Action Lists): Document collecting $_sdata. (Listing Static Tracepoint Markers): New subsection. (Tracepoints support in gdbserver): Mention static tracepoints. (remote packets, enabling and disabling): Mention read-sdata-object. (General Query Packets) <qSupported>: Document qXfer:sdata:read and StaticTracepoint. Mention qTfSTM, qTsSTM and qTSTMat as tracepoint packets. Document qXfer:sdata:read. (Tracepoint packets): Document qTfSTM, qTsSTM and qTSTMat.
2010-07-01 12:36:12 +02:00
#endif