2006-11-22 18:34:15 +01:00
|
|
|
/* Low level interface to SPUs, for the remote server for GDB.
|
2014-01-01 04:54:24 +01:00
|
|
|
Copyright (C) 2006-2014 Free Software Foundation, Inc.
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
Contributed by Ulrich Weigand <uweigand@de.ibm.com>.
|
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-08-23 20:08:50 +02:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2006-11-22 18:34:15 +01:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 20:08:50 +02:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
#include "server.h"
|
|
|
|
|
2012-11-15 17:12:19 +01:00
|
|
|
#include "gdb_wait.h"
|
2006-11-22 18:34:15 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/ptrace.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <sys/syscall.h>
|
2013-08-28 19:40:58 +02:00
|
|
|
#include "filestuff.h"
|
2013-09-05 22:45:39 +02:00
|
|
|
#include "hostio.h"
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
/* Some older glibc versions do not define this. */
|
|
|
|
#ifndef __WNOTHREAD
|
|
|
|
#define __WNOTHREAD 0x20000000 /* Don't wait on children of other
|
* i387-fp.c, linux-arm-low.c, linux-cris-low.c,
linux-crisv32-low.c, linux-i386-low.c, linux-low.c,
linux-mips-low.c, linux-s390-low.c, linux-sparc-low.c,
linux-x86-64-low.c, linux-xtensa-low.c, proc-service.c,
regcache.c, remote-utils.c, server.c, spu-low.c, target.h,
thread-db.c, win32-low.c, xtensa-xtregs.c, gdbreplay.c,
Makefile.in, configure.ac: Fix whitespace throughout.
* configure: Regenerate.
2009-03-23 00:57:10 +01:00
|
|
|
threads in this group */
|
2006-11-22 18:34:15 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define PTRACE_TYPE_RET long
|
|
|
|
#define PTRACE_TYPE_ARG3 long
|
|
|
|
|
|
|
|
/* Number of registers. */
|
|
|
|
#define SPU_NUM_REGS 130
|
|
|
|
#define SPU_NUM_CORE_REGS 128
|
|
|
|
|
|
|
|
/* Special registers. */
|
|
|
|
#define SPU_ID_REGNUM 128
|
|
|
|
#define SPU_PC_REGNUM 129
|
|
|
|
|
|
|
|
/* PPU side system calls. */
|
|
|
|
#define INSTR_SC 0x44000002
|
|
|
|
#define NR_spu_run 0x0116
|
|
|
|
|
|
|
|
/* These are used in remote-utils.c. */
|
|
|
|
int using_threads = 0;
|
|
|
|
|
2008-02-27 04:27:40 +01:00
|
|
|
/* Defined in auto-generated file reg-spu.c. */
|
|
|
|
void init_registers_spu (void);
|
[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
|
|
|
extern const struct target_desc *tdesc_spu;
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
/* Fetch PPU register REGNO. */
|
|
|
|
static CORE_ADDR
|
|
|
|
fetch_ppc_register (int regno)
|
|
|
|
{
|
|
|
|
PTRACE_TYPE_RET res;
|
|
|
|
|
2009-04-03 16:38:39 +02:00
|
|
|
int tid = ptid_get_lwp (current_ptid);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
#ifndef __powerpc64__
|
|
|
|
/* If running as a 32-bit process on a 64-bit system, we attempt
|
|
|
|
to get the full 64-bit register content of the target process.
|
|
|
|
If the PPC special ptrace call fails, we're on a 32-bit system;
|
|
|
|
just fall through to the regular ptrace call in that case. */
|
|
|
|
{
|
|
|
|
char buf[8];
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
|
|
|
|
(PTRACE_TYPE_ARG3) (regno * 8), buf);
|
|
|
|
if (errno == 0)
|
|
|
|
ptrace (PPC_PTRACE_PEEKUSR_3264, tid,
|
|
|
|
(PTRACE_TYPE_ARG3) (regno * 8 + 4), buf + 4);
|
|
|
|
if (errno == 0)
|
|
|
|
return (CORE_ADDR) *(unsigned long long *)buf;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
res = ptrace (PT_READ_U, tid,
|
* i387-fp.c, linux-arm-low.c, linux-cris-low.c,
linux-crisv32-low.c, linux-i386-low.c, linux-low.c,
linux-mips-low.c, linux-s390-low.c, linux-sparc-low.c,
linux-x86-64-low.c, linux-xtensa-low.c, proc-service.c,
regcache.c, remote-utils.c, server.c, spu-low.c, target.h,
thread-db.c, win32-low.c, xtensa-xtregs.c, gdbreplay.c,
Makefile.in, configure.ac: Fix whitespace throughout.
* configure: Regenerate.
2009-03-23 00:57:10 +01:00
|
|
|
(PTRACE_TYPE_ARG3) (regno * sizeof (PTRACE_TYPE_RET)), 0);
|
2006-11-22 18:34:15 +01:00
|
|
|
if (errno != 0)
|
|
|
|
{
|
|
|
|
char mess[128];
|
|
|
|
sprintf (mess, "reading PPC register #%d", regno);
|
|
|
|
perror_with_name (mess);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (CORE_ADDR) (unsigned long) res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch WORD from PPU memory at (aligned) MEMADDR in thread TID. */
|
|
|
|
static int
|
|
|
|
fetch_ppc_memory_1 (int tid, CORE_ADDR memaddr, PTRACE_TYPE_RET *word)
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
|
|
|
|
#ifndef __powerpc64__
|
|
|
|
if (memaddr >> 32)
|
|
|
|
{
|
|
|
|
unsigned long long addr_8 = (unsigned long long) memaddr;
|
|
|
|
ptrace (PPC_PTRACE_PEEKTEXT_3264, tid, (PTRACE_TYPE_ARG3) &addr_8, word);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
*word = ptrace (PT_READ_I, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, 0);
|
|
|
|
|
|
|
|
return errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store WORD into PPU memory at (aligned) MEMADDR in thread TID. */
|
|
|
|
static int
|
|
|
|
store_ppc_memory_1 (int tid, CORE_ADDR memaddr, PTRACE_TYPE_RET word)
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
|
|
|
|
#ifndef __powerpc64__
|
|
|
|
if (memaddr >> 32)
|
|
|
|
{
|
|
|
|
unsigned long long addr_8 = (unsigned long long) memaddr;
|
|
|
|
ptrace (PPC_PTRACE_POKEDATA_3264, tid, (PTRACE_TYPE_ARG3) &addr_8, word);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
ptrace (PT_WRITE_D, tid, (PTRACE_TYPE_ARG3) (size_t) memaddr, word);
|
|
|
|
|
|
|
|
return errno;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch LEN bytes of PPU memory at MEMADDR to MYADDR. */
|
|
|
|
static int
|
|
|
|
fetch_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
|
|
|
{
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_TYPE_RET);
|
|
|
|
int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
|
|
|
|
/ sizeof (PTRACE_TYPE_RET));
|
|
|
|
PTRACE_TYPE_RET *buffer;
|
|
|
|
|
2009-04-03 16:38:39 +02:00
|
|
|
int tid = ptid_get_lwp (current_ptid);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
|
|
|
|
for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
|
|
|
|
if ((ret = fetch_ppc_memory_1 (tid, addr, &buffer[i])) != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
memcpy (myaddr,
|
|
|
|
(char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
|
|
|
|
len);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store LEN bytes from MYADDR to PPU memory at MEMADDR. */
|
|
|
|
static int
|
|
|
|
store_ppc_memory (CORE_ADDR memaddr, char *myaddr, int len)
|
|
|
|
{
|
|
|
|
int i, ret;
|
|
|
|
|
|
|
|
CORE_ADDR addr = memaddr & -(CORE_ADDR) sizeof (PTRACE_TYPE_RET);
|
|
|
|
int count = ((((memaddr + len) - addr) + sizeof (PTRACE_TYPE_RET) - 1)
|
|
|
|
/ sizeof (PTRACE_TYPE_RET));
|
|
|
|
PTRACE_TYPE_RET *buffer;
|
|
|
|
|
2009-04-03 16:38:39 +02:00
|
|
|
int tid = ptid_get_lwp (current_ptid);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
buffer = (PTRACE_TYPE_RET *) alloca (count * sizeof (PTRACE_TYPE_RET));
|
|
|
|
|
|
|
|
if (addr != memaddr || len < (int) sizeof (PTRACE_TYPE_RET))
|
|
|
|
if ((ret = fetch_ppc_memory_1 (tid, addr, &buffer[0])) != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (count > 1)
|
|
|
|
if ((ret = fetch_ppc_memory_1 (tid, addr + (count - 1)
|
|
|
|
* sizeof (PTRACE_TYPE_RET),
|
|
|
|
&buffer[count - 1])) != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
memcpy ((char *) buffer + (memaddr & (sizeof (PTRACE_TYPE_RET) - 1)),
|
* i387-fp.c, linux-arm-low.c, linux-cris-low.c,
linux-crisv32-low.c, linux-i386-low.c, linux-low.c,
linux-mips-low.c, linux-s390-low.c, linux-sparc-low.c,
linux-x86-64-low.c, linux-xtensa-low.c, proc-service.c,
regcache.c, remote-utils.c, server.c, spu-low.c, target.h,
thread-db.c, win32-low.c, xtensa-xtregs.c, gdbreplay.c,
Makefile.in, configure.ac: Fix whitespace throughout.
* configure: Regenerate.
2009-03-23 00:57:10 +01:00
|
|
|
myaddr, len);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
for (i = 0; i < count; i++, addr += sizeof (PTRACE_TYPE_RET))
|
|
|
|
if ((ret = store_ppc_memory_1 (tid, addr, buffer[i])) != 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* If the PPU thread is currently stopped on a spu_run system call,
|
|
|
|
return to FD and ADDR the file handle and NPC parameter address
|
|
|
|
used with the system call. Return non-zero if successful. */
|
* i387-fp.c, linux-arm-low.c, linux-cris-low.c,
linux-crisv32-low.c, linux-i386-low.c, linux-low.c,
linux-mips-low.c, linux-s390-low.c, linux-sparc-low.c,
linux-x86-64-low.c, linux-xtensa-low.c, proc-service.c,
regcache.c, remote-utils.c, server.c, spu-low.c, target.h,
thread-db.c, win32-low.c, xtensa-xtregs.c, gdbreplay.c,
Makefile.in, configure.ac: Fix whitespace throughout.
* configure: Regenerate.
2009-03-23 00:57:10 +01:00
|
|
|
static int
|
2006-11-22 18:34:15 +01:00
|
|
|
parse_spufs_run (int *fd, CORE_ADDR *addr)
|
|
|
|
{
|
2012-04-05 13:20:50 +02:00
|
|
|
unsigned int insn;
|
2006-11-22 18:34:15 +01:00
|
|
|
CORE_ADDR pc = fetch_ppc_register (32); /* nip */
|
|
|
|
|
|
|
|
/* Fetch instruction preceding current NIP. */
|
2012-04-05 13:20:50 +02:00
|
|
|
if (fetch_ppc_memory (pc-4, (char *) &insn, 4) != 0)
|
2006-11-22 18:34:15 +01:00
|
|
|
return 0;
|
|
|
|
/* It should be a "sc" instruction. */
|
2012-04-05 13:20:50 +02:00
|
|
|
if (insn != INSTR_SC)
|
2006-11-22 18:34:15 +01:00
|
|
|
return 0;
|
|
|
|
/* System call number should be NR_spu_run. */
|
|
|
|
if (fetch_ppc_register (0) != NR_spu_run)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Register 3 contains fd, register 4 the NPC param pointer. */
|
|
|
|
*fd = fetch_ppc_register (34); /* orig_gpr3 */
|
|
|
|
*addr = fetch_ppc_register (4);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Copy LEN bytes at OFFSET in spufs file ANNEX into/from READBUF or WRITEBUF,
|
|
|
|
using the /proc file system. */
|
|
|
|
static int
|
|
|
|
spu_proc_xfer_spu (const char *annex, unsigned char *readbuf,
|
|
|
|
const unsigned char *writebuf,
|
|
|
|
CORE_ADDR offset, int len)
|
|
|
|
{
|
|
|
|
char buf[128];
|
|
|
|
int fd = 0;
|
|
|
|
int ret = -1;
|
|
|
|
|
|
|
|
if (!annex)
|
|
|
|
return 0;
|
|
|
|
|
2009-04-03 16:38:39 +02:00
|
|
|
sprintf (buf, "/proc/%ld/fd/%s", ptid_get_lwp (current_ptid), annex);
|
2006-11-22 18:34:15 +01:00
|
|
|
fd = open (buf, writebuf? O_WRONLY : O_RDONLY);
|
|
|
|
if (fd <= 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (offset != 0
|
|
|
|
&& lseek (fd, (off_t) offset, SEEK_SET) != (off_t) offset)
|
|
|
|
{
|
|
|
|
close (fd);
|
2007-06-12 16:31:26 +02:00
|
|
|
return 0;
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (writebuf)
|
|
|
|
ret = write (fd, writebuf, (size_t) len);
|
|
|
|
else if (readbuf)
|
|
|
|
ret = read (fd, readbuf, (size_t) len);
|
|
|
|
|
|
|
|
close (fd);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Start an inferior process and returns its pid.
|
|
|
|
ALLARGS is a vector of program-name and args. */
|
|
|
|
static int
|
|
|
|
spu_create_inferior (char *program, char **allargs)
|
|
|
|
{
|
|
|
|
int 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
|
|
|
ptid_t 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
|
|
|
struct process_info *proc;
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
pid = fork ();
|
|
|
|
if (pid < 0)
|
|
|
|
perror_with_name ("fork");
|
|
|
|
|
|
|
|
if (pid == 0)
|
|
|
|
{
|
2013-08-28 19:40:58 +02:00
|
|
|
close_most_fds ();
|
2006-11-22 18:34:15 +01:00
|
|
|
ptrace (PTRACE_TRACEME, 0, 0, 0);
|
|
|
|
|
|
|
|
setpgid (0, 0);
|
|
|
|
|
2007-06-20 20:54:21 +02:00
|
|
|
execv (program, allargs);
|
|
|
|
if (errno == ENOENT)
|
|
|
|
execvp (program, allargs);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
fprintf (stderr, "Cannot exec %s: %s.\n", program,
|
|
|
|
strerror (errno));
|
|
|
|
fflush (stderr);
|
|
|
|
_exit (0177);
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
proc = add_process (pid, 0);
|
|
|
|
proc->tdesc = tdesc_spu;
|
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
|
|
|
|
|
|
|
ptid = ptid_build (pid, pid, 0);
|
|
|
|
add_thread (ptid, NULL);
|
2006-11-22 18:34:15 +01:00
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Attach to an inferior process. */
|
|
|
|
int
|
|
|
|
spu_attach (unsigned long 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
|
|
|
ptid_t 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
|
|
|
struct process_info *proc;
|
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
|
|
|
|
2006-11-22 18:34:15 +01:00
|
|
|
if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0)
|
|
|
|
{
|
|
|
|
fprintf (stderr, "Cannot attach to process %ld: %s (%d)\n", pid,
|
|
|
|
strerror (errno), errno);
|
|
|
|
fflush (stderr);
|
|
|
|
_exit (0177);
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
proc = add_process (pid, 1);
|
|
|
|
proc->tdesc = tdesc_spu;
|
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
|
|
|
ptid = ptid_build (pid, pid, 0);
|
|
|
|
add_thread (ptid, NULL);
|
2006-11-22 18:34:15 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Kill the inferior 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
|
|
|
static int
|
2009-04-03 16:38:39 +02:00
|
|
|
spu_kill (int pid)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-09-27 22:45:20 +02:00
|
|
|
int status, ret;
|
2009-04-03 16:38:39 +02:00
|
|
|
struct process_info *process = find_process_pid (pid);
|
|
|
|
if (process == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ptrace (PTRACE_KILL, pid, 0, 0);
|
2009-09-27 22:45:20 +02:00
|
|
|
|
|
|
|
do {
|
|
|
|
ret = waitpid (pid, &status, 0);
|
|
|
|
if (WIFEXITED (status) || WIFSIGNALED (status))
|
|
|
|
break;
|
|
|
|
} while (ret != -1 || errno != ECHILD);
|
|
|
|
|
|
|
|
clear_inferiors ();
|
2009-04-03 16:38:39 +02:00
|
|
|
remove_process (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
|
|
|
return 0;
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Detach from inferior process. */
|
2007-05-10 23:33:31 +02:00
|
|
|
static int
|
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
|
|
|
spu_detach (int pid)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
struct process_info *process = find_process_pid (pid);
|
|
|
|
if (process == NULL)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ptrace (PTRACE_DETACH, pid, 0, 0);
|
2009-09-27 22:45:20 +02:00
|
|
|
|
|
|
|
clear_inferiors ();
|
2009-04-03 16:38:39 +02:00
|
|
|
remove_process (process);
|
2007-05-10 23:33:31 +02:00
|
|
|
return 0;
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
2010-04-12 19:39:42 +02:00
|
|
|
static void
|
|
|
|
spu_mourn (struct process_info *process)
|
|
|
|
{
|
|
|
|
remove_process (process);
|
|
|
|
}
|
|
|
|
|
2007-05-10 23:05:15 +02:00
|
|
|
static 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
|
|
|
spu_join (int pid)
|
2007-05-10 23:05:15 +02:00
|
|
|
{
|
|
|
|
int status, ret;
|
|
|
|
|
|
|
|
do {
|
2009-04-03 16:38:39 +02:00
|
|
|
ret = waitpid (pid, &status, 0);
|
2007-05-10 23:05:15 +02:00
|
|
|
if (WIFEXITED (status) || WIFSIGNALED (status))
|
|
|
|
break;
|
|
|
|
} while (ret != -1 || errno != ECHILD);
|
|
|
|
}
|
|
|
|
|
2006-11-22 18:34:15 +01:00
|
|
|
/* Return nonzero if the given thread is still alive. */
|
|
|
|
static int
|
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
|
|
|
spu_thread_alive (ptid_t ptid)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
return ptid_equal (ptid, current_ptid);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Resume process. */
|
|
|
|
static void
|
2009-04-02 00:29:33 +02:00
|
|
|
spu_resume (struct thread_resume *resume_info, size_t n)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-04-02 00:29:33 +02:00
|
|
|
size_t i;
|
2006-11-22 18:34:15 +01:00
|
|
|
|
2009-04-02 00:29:33 +02:00
|
|
|
for (i = 0; i < n; i++)
|
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 (ptid_equal (resume_info[i].thread, minus_one_ptid)
|
2009-04-03 16:38:39 +02:00
|
|
|
|| ptid_equal (resume_info[i].thread, current_ptid))
|
2009-04-02 00:29:33 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
if (i == n)
|
2006-11-22 18:34:15 +01:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* We don't support hardware single-stepping right now, assume
|
|
|
|
GDB knows to use software single-stepping. */
|
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 (resume_info[i].kind == resume_step)
|
2006-11-22 18:34:15 +01:00
|
|
|
fprintf (stderr, "Hardware single-step not supported.\n");
|
|
|
|
|
|
|
|
regcache_invalidate ();
|
|
|
|
|
|
|
|
errno = 0;
|
2009-04-03 16:38:39 +02:00
|
|
|
ptrace (PTRACE_CONT, ptid_get_lwp (current_ptid), 0, resume_info[i].sig);
|
2006-11-22 18:34:15 +01:00
|
|
|
if (errno)
|
|
|
|
perror_with_name ("ptrace");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for process, returns status. */
|
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 ptid_t
|
|
|
|
spu_wait (ptid_t ptid, struct target_waitstatus *ourstatus, int options)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
int pid = ptid_get_pid (ptid);
|
2006-11-22 18:34:15 +01:00
|
|
|
int w;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
ret = waitpid (pid, &w, WNOHANG | __WALL | __WNOTHREAD);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
if (ret == -1)
|
|
|
|
{
|
|
|
|
if (errno != ECHILD)
|
|
|
|
perror_with_name ("waitpid");
|
|
|
|
}
|
|
|
|
else if (ret > 0)
|
|
|
|
break;
|
|
|
|
|
|
|
|
usleep (1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* On the first wait, continue running the inferior until we are
|
|
|
|
blocked inside an spu_run system call. */
|
|
|
|
if (!server_waiting)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
while (!parse_spufs_run (&fd, &addr))
|
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
ptrace (PT_SYSCALL, pid, (PTRACE_TYPE_ARG3) 0, 0);
|
|
|
|
waitpid (pid, NULL, __WALL | __WNOTHREAD);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (WIFEXITED (w))
|
|
|
|
{
|
|
|
|
fprintf (stderr, "\nChild exited with retcode = %x \n", WEXITSTATUS (w));
|
Decouple target code from remote protocol.
* target.h (enum target_waitkind): New.
(struct target_waitstatus): New.
(struct target_ops) <wait>: Return an unsigned long. Take a
target_waitstatus pointer instead of a char pointer.
(mywait): Likewise.
* target.c (mywait): Change prototype to return an unsigned long.
Take a target_waitstatus pointer instead of a char pointer. Adjust.
* server.h (thread_from_wait, old_thread_from_wait): Delete
declarations.
(prepare_resume_reply): Change prototype to take a
target_waitstatus.
* server.c (thread_from_wait, old_thread_from_wait): Delete.
(last_status, last_ptid): New.
(start_inferior): Remove "statusptr" argument. Adjust. Return a
pid instead of a signal.
(attach_inferior): Remove "status" and "signal" parameters.
Adjust.
(handle_query): For qGetTLSAddr, parse the thread id with strtol,
not as an address.
(handle_v_cont, handle_v_attach, handle_v_run, handle_v_kill)
(handle_v_requests, myresume): Remove "status" and "signal"
parameters. Adjust.
(handle_status): New.
(main): Delete local `status'. Adjust.
* remote-utils.c: Include target.h.
(prepare_resume_reply): Change prototype to take a
target_waitstatus. Adjust.
* linux-low.c (linux_wait): Adjust to new target_ops->wait
interface.
* spu-low.c (spu_wait): Adjust.
* win32-low.c (enum target_waitkind, struct target_waitstatus):
Delete.
(win32_wait): Adjust.
2009-04-02 00:31:45 +02:00
|
|
|
ourstatus->kind = TARGET_WAITKIND_EXITED;
|
|
|
|
ourstatus->value.integer = WEXITSTATUS (w);
|
2006-11-22 18:34:15 +01:00
|
|
|
clear_inferiors ();
|
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
|
|
|
return pid_to_ptid (ret);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
else if (!WIFSTOPPED (w))
|
|
|
|
{
|
|
|
|
fprintf (stderr, "\nChild terminated with signal = %x \n", WTERMSIG (w));
|
Decouple target code from remote protocol.
* target.h (enum target_waitkind): New.
(struct target_waitstatus): New.
(struct target_ops) <wait>: Return an unsigned long. Take a
target_waitstatus pointer instead of a char pointer.
(mywait): Likewise.
* target.c (mywait): Change prototype to return an unsigned long.
Take a target_waitstatus pointer instead of a char pointer. Adjust.
* server.h (thread_from_wait, old_thread_from_wait): Delete
declarations.
(prepare_resume_reply): Change prototype to take a
target_waitstatus.
* server.c (thread_from_wait, old_thread_from_wait): Delete.
(last_status, last_ptid): New.
(start_inferior): Remove "statusptr" argument. Adjust. Return a
pid instead of a signal.
(attach_inferior): Remove "status" and "signal" parameters.
Adjust.
(handle_query): For qGetTLSAddr, parse the thread id with strtol,
not as an address.
(handle_v_cont, handle_v_attach, handle_v_run, handle_v_kill)
(handle_v_requests, myresume): Remove "status" and "signal"
parameters. Adjust.
(handle_status): New.
(main): Delete local `status'. Adjust.
* remote-utils.c: Include target.h.
(prepare_resume_reply): Change prototype to take a
target_waitstatus. Adjust.
* linux-low.c (linux_wait): Adjust to new target_ops->wait
interface.
* spu-low.c (spu_wait): Adjust.
* win32-low.c (enum target_waitkind, struct target_waitstatus):
Delete.
(win32_wait): Adjust.
2009-04-02 00:31:45 +02:00
|
|
|
ourstatus->kind = TARGET_WAITKIND_SIGNALLED;
|
2012-05-24 18:39:15 +02:00
|
|
|
ourstatus->value.sig = gdb_signal_from_host (WTERMSIG (w));
|
2006-11-22 18:34:15 +01:00
|
|
|
clear_inferiors ();
|
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
|
|
|
return pid_to_ptid (ret);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* After attach, we may have received a SIGSTOP. Do not return this
|
|
|
|
as signal to GDB, or else it will try to continue with SIGSTOP ... */
|
|
|
|
if (!server_waiting)
|
|
|
|
{
|
Decouple target code from remote protocol.
* target.h (enum target_waitkind): New.
(struct target_waitstatus): New.
(struct target_ops) <wait>: Return an unsigned long. Take a
target_waitstatus pointer instead of a char pointer.
(mywait): Likewise.
* target.c (mywait): Change prototype to return an unsigned long.
Take a target_waitstatus pointer instead of a char pointer. Adjust.
* server.h (thread_from_wait, old_thread_from_wait): Delete
declarations.
(prepare_resume_reply): Change prototype to take a
target_waitstatus.
* server.c (thread_from_wait, old_thread_from_wait): Delete.
(last_status, last_ptid): New.
(start_inferior): Remove "statusptr" argument. Adjust. Return a
pid instead of a signal.
(attach_inferior): Remove "status" and "signal" parameters.
Adjust.
(handle_query): For qGetTLSAddr, parse the thread id with strtol,
not as an address.
(handle_v_cont, handle_v_attach, handle_v_run, handle_v_kill)
(handle_v_requests, myresume): Remove "status" and "signal"
parameters. Adjust.
(handle_status): New.
(main): Delete local `status'. Adjust.
* remote-utils.c: Include target.h.
(prepare_resume_reply): Change prototype to take a
target_waitstatus. Adjust.
* linux-low.c (linux_wait): Adjust to new target_ops->wait
interface.
* spu-low.c (spu_wait): Adjust.
* win32-low.c (enum target_waitkind, struct target_waitstatus):
Delete.
(win32_wait): Adjust.
2009-04-02 00:31:45 +02:00
|
|
|
ourstatus->kind = TARGET_WAITKIND_STOPPED;
|
2012-05-24 18:51:47 +02:00
|
|
|
ourstatus->value.sig = GDB_SIGNAL_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
|
|
|
return ptid_build (ret, ret, 0);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
Decouple target code from remote protocol.
* target.h (enum target_waitkind): New.
(struct target_waitstatus): New.
(struct target_ops) <wait>: Return an unsigned long. Take a
target_waitstatus pointer instead of a char pointer.
(mywait): Likewise.
* target.c (mywait): Change prototype to return an unsigned long.
Take a target_waitstatus pointer instead of a char pointer. Adjust.
* server.h (thread_from_wait, old_thread_from_wait): Delete
declarations.
(prepare_resume_reply): Change prototype to take a
target_waitstatus.
* server.c (thread_from_wait, old_thread_from_wait): Delete.
(last_status, last_ptid): New.
(start_inferior): Remove "statusptr" argument. Adjust. Return a
pid instead of a signal.
(attach_inferior): Remove "status" and "signal" parameters.
Adjust.
(handle_query): For qGetTLSAddr, parse the thread id with strtol,
not as an address.
(handle_v_cont, handle_v_attach, handle_v_run, handle_v_kill)
(handle_v_requests, myresume): Remove "status" and "signal"
parameters. Adjust.
(handle_status): New.
(main): Delete local `status'. Adjust.
* remote-utils.c: Include target.h.
(prepare_resume_reply): Change prototype to take a
target_waitstatus. Adjust.
* linux-low.c (linux_wait): Adjust to new target_ops->wait
interface.
* spu-low.c (spu_wait): Adjust.
* win32-low.c (enum target_waitkind, struct target_waitstatus):
Delete.
(win32_wait): Adjust.
2009-04-02 00:31:45 +02:00
|
|
|
ourstatus->kind = TARGET_WAITKIND_STOPPED;
|
2012-05-24 18:39:15 +02:00
|
|
|
ourstatus->value.sig = gdb_signal_from_host (WSTOPSIG (w));
|
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
|
|
|
return ptid_build (ret, ret, 0);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fetch inferior registers. */
|
|
|
|
static void
|
2010-01-21 15:11:21 +01:00
|
|
|
spu_fetch_registers (struct regcache *regcache, int regno)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* We must be stopped on a spu_run system call. */
|
|
|
|
if (!parse_spufs_run (&fd, &addr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The ID register holds the spufs file handle. */
|
|
|
|
if (regno == -1 || regno == SPU_ID_REGNUM)
|
2010-01-21 15:11:21 +01:00
|
|
|
supply_register (regcache, SPU_ID_REGNUM, (char *)&fd);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
/* The NPC register is found at ADDR. */
|
|
|
|
if (regno == -1 || regno == SPU_PC_REGNUM)
|
|
|
|
{
|
|
|
|
char buf[4];
|
|
|
|
if (fetch_ppc_memory (addr, buf, 4) == 0)
|
2010-01-21 15:11:21 +01:00
|
|
|
supply_register (regcache, SPU_PC_REGNUM, buf);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The GPRs are found in the "regs" spufs file. */
|
|
|
|
if (regno == -1 || (regno >= 0 && regno < SPU_NUM_CORE_REGS))
|
|
|
|
{
|
|
|
|
unsigned char buf[16*SPU_NUM_CORE_REGS];
|
|
|
|
char annex[32];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
sprintf (annex, "%d/regs", fd);
|
|
|
|
if (spu_proc_xfer_spu (annex, buf, NULL, 0, sizeof buf) == sizeof buf)
|
|
|
|
for (i = 0; i < SPU_NUM_CORE_REGS; i++)
|
2010-01-21 15:11:21 +01:00
|
|
|
supply_register (regcache, i, buf + i*16);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store inferior registers. */
|
|
|
|
static void
|
2010-01-21 15:11:21 +01:00
|
|
|
spu_store_registers (struct regcache *regcache, int regno)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
CORE_ADDR addr;
|
|
|
|
|
|
|
|
/* ??? Some callers use 0 to mean all registers. */
|
|
|
|
if (regno == 0)
|
|
|
|
regno = -1;
|
|
|
|
|
|
|
|
/* We must be stopped on a spu_run system call. */
|
|
|
|
if (!parse_spufs_run (&fd, &addr))
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* The NPC register is found at ADDR. */
|
|
|
|
if (regno == -1 || regno == SPU_PC_REGNUM)
|
|
|
|
{
|
|
|
|
char buf[4];
|
2010-01-21 15:11:21 +01:00
|
|
|
collect_register (regcache, SPU_PC_REGNUM, buf);
|
2006-11-22 18:34:15 +01:00
|
|
|
store_ppc_memory (addr, buf, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The GPRs are found in the "regs" spufs file. */
|
|
|
|
if (regno == -1 || (regno >= 0 && regno < SPU_NUM_CORE_REGS))
|
|
|
|
{
|
|
|
|
unsigned char buf[16*SPU_NUM_CORE_REGS];
|
|
|
|
char annex[32];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < SPU_NUM_CORE_REGS; i++)
|
2010-01-21 15:11:21 +01:00
|
|
|
collect_register (regcache, i, buf + i*16);
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
sprintf (annex, "%d/regs", fd);
|
|
|
|
spu_proc_xfer_spu (annex, NULL, buf, 0, sizeof buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy LEN bytes from inferior's memory starting at MEMADDR
|
|
|
|
to debugger memory starting at MYADDR. */
|
|
|
|
static int
|
|
|
|
spu_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len)
|
|
|
|
{
|
|
|
|
int fd, ret;
|
|
|
|
CORE_ADDR addr;
|
2010-06-19 19:36:51 +02:00
|
|
|
char annex[32], lslr_annex[32], buf[32];
|
|
|
|
CORE_ADDR lslr;
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
/* We must be stopped on a spu_run system call. */
|
|
|
|
if (!parse_spufs_run (&fd, &addr))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Use the "mem" spufs file to access SPU local store. */
|
|
|
|
sprintf (annex, "%d/mem", fd);
|
|
|
|
ret = spu_proc_xfer_spu (annex, myaddr, NULL, memaddr, len);
|
2010-06-19 19:36:51 +02:00
|
|
|
if (ret > 0)
|
|
|
|
return ret == len ? 0 : EIO;
|
|
|
|
|
|
|
|
/* SPU local store access wraps the address around at the
|
|
|
|
local store limit. We emulate this here. To avoid needing
|
|
|
|
an extra access to retrieve the LSLR, we only do that after
|
|
|
|
trying the original address first, and getting end-of-file. */
|
|
|
|
sprintf (lslr_annex, "%d/lslr", fd);
|
|
|
|
memset (buf, 0, sizeof buf);
|
|
|
|
if (spu_proc_xfer_spu (lslr_annex, (unsigned char *)buf, NULL,
|
|
|
|
0, sizeof buf) <= 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
lslr = strtoul (buf, NULL, 16);
|
|
|
|
ret = spu_proc_xfer_spu (annex, myaddr, NULL, memaddr & lslr, len);
|
|
|
|
|
2006-11-22 18:34:15 +01:00
|
|
|
return ret == len ? 0 : EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy LEN bytes of data from debugger memory at MYADDR
|
|
|
|
to inferior's memory at MEMADDR.
|
|
|
|
On failure (cannot write the inferior)
|
|
|
|
returns the value of errno. */
|
|
|
|
static int
|
|
|
|
spu_write_memory (CORE_ADDR memaddr, const unsigned char *myaddr, int len)
|
|
|
|
{
|
|
|
|
int fd, ret;
|
|
|
|
CORE_ADDR addr;
|
2010-06-19 19:36:51 +02:00
|
|
|
char annex[32], lslr_annex[32], buf[32];
|
|
|
|
CORE_ADDR lslr;
|
2006-11-22 18:34:15 +01:00
|
|
|
|
|
|
|
/* We must be stopped on a spu_run system call. */
|
|
|
|
if (!parse_spufs_run (&fd, &addr))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* Use the "mem" spufs file to access SPU local store. */
|
|
|
|
sprintf (annex, "%d/mem", fd);
|
|
|
|
ret = spu_proc_xfer_spu (annex, NULL, myaddr, memaddr, len);
|
2010-06-19 19:36:51 +02:00
|
|
|
if (ret > 0)
|
|
|
|
return ret == len ? 0 : EIO;
|
|
|
|
|
|
|
|
/* SPU local store access wraps the address around at the
|
|
|
|
local store limit. We emulate this here. To avoid needing
|
|
|
|
an extra access to retrieve the LSLR, we only do that after
|
|
|
|
trying the original address first, and getting end-of-file. */
|
|
|
|
sprintf (lslr_annex, "%d/lslr", fd);
|
|
|
|
memset (buf, 0, sizeof buf);
|
|
|
|
if (spu_proc_xfer_spu (lslr_annex, (unsigned char *)buf, NULL,
|
|
|
|
0, sizeof buf) <= 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
lslr = strtoul (buf, NULL, 16);
|
|
|
|
ret = spu_proc_xfer_spu (annex, NULL, myaddr, memaddr & lslr, len);
|
|
|
|
|
2006-11-22 18:34:15 +01:00
|
|
|
return ret == len ? 0 : EIO;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Look up special symbols -- unneded here. */
|
|
|
|
static void
|
|
|
|
spu_look_up_symbols (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send signal to inferior. */
|
|
|
|
static void
|
2007-02-25 18:59:43 +01:00
|
|
|
spu_request_interrupt (void)
|
2006-11-22 18:34:15 +01:00
|
|
|
{
|
2009-04-03 16:38:39 +02:00
|
|
|
syscall (SYS_tkill, ptid_get_lwp (current_ptid), SIGINT);
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct target_ops spu_target_ops = {
|
|
|
|
spu_create_inferior,
|
|
|
|
spu_attach,
|
|
|
|
spu_kill,
|
|
|
|
spu_detach,
|
2010-04-12 19:39:42 +02:00
|
|
|
spu_mourn,
|
2007-05-10 23:05:15 +02:00
|
|
|
spu_join,
|
2006-11-22 18:34:15 +01:00
|
|
|
spu_thread_alive,
|
|
|
|
spu_resume,
|
|
|
|
spu_wait,
|
|
|
|
spu_fetch_registers,
|
|
|
|
spu_store_registers,
|
2010-08-27 01:17:22 +02:00
|
|
|
NULL, /* prepare_to_access_memory */
|
2010-08-27 02:16:48 +02:00
|
|
|
NULL, /* done_accessing_memory */
|
2006-11-22 18:34:15 +01:00
|
|
|
spu_read_memory,
|
|
|
|
spu_write_memory,
|
|
|
|
spu_look_up_symbols,
|
2007-02-25 18:59:43 +01:00
|
|
|
spu_request_interrupt,
|
2006-11-22 18:34:15 +01:00
|
|
|
NULL,
|
2007-02-22 18:41:37 +01:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
2007-06-12 16:38:32 +02:00
|
|
|
spu_proc_xfer_spu,
|
2008-02-01 01:08:25 +01:00
|
|
|
hostio_last_error_from_errno,
|
2006-11-22 18:34:15 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
initialize_low (void)
|
|
|
|
{
|
|
|
|
static const unsigned char breakpoint[] = { 0x00, 0x00, 0x3f, 0xff };
|
|
|
|
|
|
|
|
set_target_ops (&spu_target_ops);
|
|
|
|
set_breakpoint_data (breakpoint, sizeof breakpoint);
|
2008-02-27 04:27:40 +01:00
|
|
|
init_registers_spu ();
|
2006-11-22 18:34:15 +01:00
|
|
|
}
|