Commit Graph

32 Commits

Author SHA1 Message Date
Tom Tromey 98a0328732 Share Windows thread-suspend and -resume code
This adds "suspend" and "resume" methods to windows_thread_info, and
changes gdb and gdbserver to share this code.

gdb/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

	* windows-nat.c (thread_rec): Use windows_thread_info::suspend.
	(windows_continue): Use windows_continue::resume.
	* nat/windows-nat.h (struct windows_thread_info) <suspend,
	resume>: Declare new methods.
	* nat/windows-nat.c: New file.
	* configure.nat (NATDEPFILES): Add nat/windows-nat.o when needed.

gdbserver/ChangeLog
2020-04-08  Tom Tromey  <tromey@adacore.com>

	* win32-low.c (win32_require_context, suspend_one_thread): Use
	windows_thread_info::suspend.
	(continue_one_thread): Use windows_thread_info::resume.
	* configure.srv (srv_tgtobj): Add windows-nat.o when needed.
2020-04-08 14:47:58 -06:00
Hannes Domani 46f9f93119 Implement debugging of WOW64 processes
For WOW64 processes, the Wow64* variants of SuspendThread,
GetThreadContext, SetThreadContext, and GetThreadSelectorEntry have to
be used instead.
And instead of EnumProcessModules, EnumProcessModulesEx with
LIST_MODULES_32BIT is necessary.

gdb/ChangeLog:

2020-03-04  Hannes Domani  <ssbssa@yahoo.de>

	* NEWS: Mention support for WOW64 processes.
	* amd64-windows-nat.c (amd64_mappings): Rename and remove static.
	(amd64_windows_segment_register_p): Remove static.
	(_initialize_amd64_windows_nat): Update.
	* configure.nat <windows> (NATDEPFILES): Add i386-windows-nat.o.
	* i386-windows-nat.c (context_offset): Update.
	(i386_mappings): Rename and remove static.
	(i386_windows_segment_register_p): Remove static.
	(_initialize_i386_windows_nat): Update.
	* windows-nat.c (STATUS_WX86_BREAKPOINT): New macro.
	(STATUS_WX86_SINGLE_STEP): New macro.
	(EnumProcessModulesEx): New macro.
	(Wow64SuspendThread): New macro.
	(Wow64GetThreadContext): New macro.
	(Wow64SetThreadContext): New macro.
	(Wow64GetThreadSelectorEntry): New macro.
	(windows_set_context_register_offsets): Add static.
	(windows_set_segment_register_p): Likewise.
	(windows_add_thread): Adapt for WOW64 processes.
	(windows_fetch_one_register): Likewise.
	(windows_nat_target::fetch_registers): Likewise.
	(windows_store_one_register): Likewise.
	(display_selector): Likewise.
	(display_selectors): Likewise.
	(handle_exception): Likewise.
	(windows_continue): Likewise.
	(windows_nat_target::resume): Likewise.
	(windows_add_all_dlls): Likewise.
	(do_initial_windows_stuff): Likewise.
	(windows_nat_target::attach): Likewise.
	(windows_get_exec_module_filename): Likewise.
	(windows_nat_target::create_inferior): Likewise.
	(windows_xfer_siginfo): Likewise.
	(_initialize_loadable): Initialize Wow64SuspendThread,
	Wow64GetThreadContext, Wow64SetThreadContext,
	Wow64GetThreadSelectorEntry and EnumProcessModulesEx.
	* windows-nat.h (windows_set_context_register_offsets):
	Remove declaration.
	(windows_set_segment_register_p): Likewise.
	(i386_windows_segment_register_p): Add declaration.
	(amd64_windows_segment_register_p): Likewise.
2020-03-04 21:15:20 +01:00
Maciej W. Rozycki f6480e7000 RISC-V/Linux/native: Factor out target description determination
In preparation for RISC-V/Linux `gdbserver' support factor out parts of
native target description determination code that can be shared between
the programs.

	gdb/
	* nat/riscv-linux-tdesc.h: New file.
	* nat/riscv-linux-tdesc.c: New file, taking code from...
	* riscv-linux-nat.c (riscv_linux_nat_target::read_description):
	... here.
	* configure.nat <linux> <riscv*>: Add nat/riscv-linux-tdesc.o to
	NATDEPFILES.
2020-02-05 17:21:12 +00:00
Joel Brobecker b811d2c292 Update copyright year range in all GDB files.
gdb/ChangeLog:

        Update copyright year range in all GDB files.
2020-01-01 10:20:53 +04:00
Christian Biesinger 3a8fa2282b Fix (most) OpenBSD link errors
This fixes these errors:
ld: error: undefined symbol: x86_stopped_by_hw_breakpoint()
>>> referenced by x86-nat.h:109 (../../gdb/x86-nat.h:109)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_by_hw_breakpoint())

ld: error: undefined symbol: x86_can_use_hw_breakpoint(bptype, int, int)
>>> referenced by x86-nat.h:76 (../../gdb/x86-nat.h:76)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::can_use_hw_breakpoint(bptype, int, int))

ld: error: undefined symbol: x86_insert_hw_breakpoint(gdbarch*, bp_target_info*)
>>> referenced by x86-nat.h:93 (../../gdb/x86-nat.h:93)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::insert_hw_breakpoint(gdbarch*, bp_target_info*))

ld: error: undefined symbol: x86_remove_hw_breakpoint(gdbarch*, bp_target_info*)
>>> referenced by x86-nat.h:97 (../../gdb/x86-nat.h:97)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::remove_hw_breakpoint(gdbarch*, bp_target_info*))

ld: error: undefined symbol: x86_remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*)
>>> referenced by x86-nat.h:89 (../../gdb/x86-nat.h:89)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*))

ld: error: undefined symbol: x86_insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*)
>>> referenced by x86-nat.h:84 (../../gdb/x86-nat.h:84)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*))

ld: error: undefined symbol: x86_stopped_by_watchpoint()
>>> referenced by x86-nat.h:100 (../../gdb/x86-nat.h:100)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_by_watchpoint())

ld: error: undefined symbol: x86_stopped_data_address(unsigned long*)
>>> referenced by x86-nat.h:103 (../../gdb/x86-nat.h:103)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::stopped_data_address(unsigned long*))

ld: error: undefined symbol: x86_region_ok_for_hw_watchpoint(unsigned long, int)
>>> referenced by x86-nat.h:79 (../../gdb/x86-nat.h:79)
>>>               amd64-obsd-nat.o:(x86_nat_target<obsd_nat_target>::region_ok_for_hw_watchpoint(unsigned long, int))

and

ld: error: undefined symbol: x86_dr_insert_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int)
>>> referenced by x86-nat.c:156 (../../gdb/x86-nat.c:156)
>>>               x86-nat.o:(x86_insert_watchpoint(unsigned long, int, target_hw_bp_type, expression*))

ld: error: undefined symbol: x86_dr_remove_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int)
>>> referenced by x86-nat.c:169 (../../gdb/x86-nat.c:169)
>>>               x86-nat.o:(x86_remove_watchpoint(unsigned long, int, target_hw_bp_type, expression*))

ld: error: undefined symbol: x86_dr_region_ok_for_watchpoint(x86_debug_reg_state*, unsigned long, int)
>>> referenced by x86-nat.c:181 (../../gdb/x86-nat.c:181)
>>>               x86-nat.o:(x86_region_ok_for_hw_watchpoint(unsigned long, int))

ld: error: undefined symbol: x86_dr_stopped_data_address(x86_debug_reg_state*, unsigned long*)
>>> referenced by x86-nat.c:194 (../../gdb/x86-nat.c:194)
>>>               x86-nat.o:(x86_stopped_data_address(unsigned long*))

ld: error: undefined symbol: x86_dr_stopped_by_watchpoint(x86_debug_reg_state*)
>>> referenced by x86-nat.c:206 (../../gdb/x86-nat.c:206)
>>>               x86-nat.o:(x86_stopped_by_watchpoint())

ld: error: undefined symbol: x86_dr_insert_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int)
>>> referenced by x86-nat.c:219 (../../gdb/x86-nat.c:219)
>>>               x86-nat.o:(x86_insert_hw_breakpoint(gdbarch*, bp_target_info*))

ld: error: undefined symbol: x86_dr_remove_watchpoint(x86_debug_reg_state*, target_hw_bp_type, unsigned long, int)
>>> referenced by x86-nat.c:233 (../../gdb/x86-nat.c:233)
>>>               x86-nat.o:(x86_remove_hw_breakpoint(gdbarch*, bp_target_info*))

ld: error: undefined symbol: x86_dr_stopped_by_hw_breakpoint(x86_debug_reg_state*)
>>> referenced by x86-nat.c:269 (../../gdb/x86-nat.c:269)
>>>               x86-nat.o:(x86_stopped_by_hw_breakpoint())

It does not fix:
ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in /usr/local/lib/libgmp.a(mp_minv_tab.o)
>>> referenced by tmp-dive_1.s
>>>               dive_1.o:(__gmpn_divexact_1) in archive /usr/local/lib/libgmp.a

ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmp_binvert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in /usr/local/lib/libgmp.a(mp_minv_tab.o)
>>> referenced by tmp-bdiv_q_1.s
>>>               bdiv_q_1.o:(__gmpn_bdiv_q_1) in archive /usr/local/lib/libgmp.a

ld: error: can't create dynamic relocation R_X86_64_64 against symbol: __gmpn_invert_limb_table in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output
>>> defined in /usr/local/lib/libgmp.a(invert_limb_table.o)
>>> referenced by tmp-invert_limb.s
>>>               invert_limb.o:(__gmpn_invert_limb) in archive /usr/local/lib/libgmp.a

gdb/ChangeLog:

2019-12-04  Christian Biesinger  <cbiesinger@google.com>

	* configure.nat (obsd64): Add missing files x86-nat.o and
	nat/x86-dregs.o.

Change-Id: I4a443c0cf805efd7b45feaabd729a01b07772724
2019-12-04 16:15:18 -06:00
Ulrich Weigand abf516c693 Remove Cell Broadband Engine debugging support
This patch implements removal of Cell/B.E. support, including
- Support for the spu-*-* target
- Support for native stand-alone SPU debugging
- Support for integrated debugging of combined PPU/SPU applications
- Remote debugging (gdbserver) support for all the above.

The patch also removes the TARGET_OBJECT_SPU target object type,
as this is available only on Cell/B.E. targets, including
- Native Linux support
- Core file support (including core file generation)
- Remote target support, including removal of the qXfer:spu:read
  and qXfer:spu:write remote protocal packets and associated
  support in gdbserver.

gdb/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* NEWS: Mention that Cell/B.E. debugging support was removed.
	* MAINTAINERS: Remove spu target.

	* config/djgpp/fnchange.lst: Remove entries for removed files.

	* Makefile.in (ALL_TARGET_OBS): Remove solib-spu.o,
	spu-multiarch.o, and spu-tdep.o.
	(HFILES_NO_SRCDIR): Remove solib-spu.h and spu-tdep.h.
	(ALLDEPFILES): Remove solib-spu.c, spu-linux-nat.c,
	spu-multiarch.c, and spu-tdep.c.
	* spu-linux-nat.c: Remove file.
	* spu-multiarch.c: Remove file.
	* spu-tdep.c: Remove file.
	* spu-tdep.h: Remove file.
	* solib-spu.c: Remove file.
	* solib-spu.h: Remove file.

	* configure.host (powerpc64*-*-linux*): Remove Cell/B.E. support.
	* configure.nat (spu-linux): Remove.
	* configure.tgt (powerpc*-*-linux*): Remove solib-spu.o and
	solib-multiarch.o from gdb_target_obs.
	(spu*-*-*): Remove.

	* arch/ppc-linux-common.h (struct ppc_linux_features): Remove "cell"
	feature flag.
	(ppc_linux_no_features): Update.
	* arch/ppc-linux-common.c (ppc_linux_match_description): Remove
	Cell/B.E. support.
	* arch/ppc-linux-tdesc.h (tdesc_powerpc_cell32l): Remove declaration.
	(tdesc_powerpc_cell64l): Likewise.
	* nat/ppc-linux.h (PPC_FEATURE_CELL): Remove.
	* ppc-linux-nat.c (ppc_linux_nat_target::read_description): Remove
	Cell/B.E. support.
	* ppc-linux-tdep.h: Do not include "solib-spu.h" or "spu-tdep.h".
	Do not include "features/rs6000/powerpc-cell32l.c" or
	"features/rs6000/powerpc-cell64l.c".
	(ppc_linux_spu_section): Remove.
	(ppc_linux_core_read_description): Remove Cell/B.E. support.
	(spe_context_objfile, spe_context_lm_addr, spe_context_offset,
	spe_context_cache_ptid, spe_context_cache_ptid): Remove.
	(ppc_linux_spe_context_lookup): Remove.
	(ppc_linux_spe_context_inferior_created): Remove.
	(ppc_linux_spe_context_solib_loaded): Remove.
	(ppc_linux_spe_context_solib_unloaded): Remove.
	(ppc_linux_spe_context): Remove.
	(struct ppu2spu_cache): Remove.
	(ppu2spu_prev_arch, ppu2spu_this_id, ppu2spu_prev_register): Remove.
	(struct ppu2spu_data): Remove.
	(ppu2spu_unwind_register, ppu2spu_sniffer, ppu2spu_dealloc_cache,
	ppu2spu_unwind): Remove.
	(ppc_linux_init_abi): Remove Cell/B.E. support.
	* rs6000-tdep.h (rs6000_gdbarch_init): Remove Cell/B.E. support.

	* features/Makefile (rs6000/powerpc-cell32l-expedite): Remove.
	(rs6000/powerpc-cell64l-expedite): Likewise
	(WHICH): Remove rs6000/powerpc-cell32l and rs6000/powerpc-cell64l.
	(XMLTOC): Remove rs6000/powerpc-cell32l.xml and
	rs6000/powerpc-cell64l.xml.
	* features/rs6000/powerpc-cell32l.xml: Remove.
	* features/rs6000/powerpc-cell64l.xml: Likewise.
	* features/rs6000/powerpc-cell32l.c: Remove generated file.
	* features/rs6000/powerpc-cell64l.c: Likewise.
	* regformats/rs6000/powerpc-cell32l.dat: Remove generated file.
	* regformats/rs6000/powerpc-cell64l.dat: Likewise.
	* regformats/reg-spu.dat: Remove.

	* target.h (enum target_object): Remove TARGET_OBJECT_SPU.
	* corelow.c (struct spuid_list): Remove.
	(add_to_spuid_list): Remove.
	(core_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* remote.c (PACKET_qXfer_spu_read, PACKET_qXfer_spu_write): Remove.
	(remote_protocol_features): Remove associated entries.
	(_initialize_remote): No longer initialize them.
	(remote_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* linux-nat.c (SPUFS_MAGIC): Remove.
	(linux_proc_xfer_spu): Remove.
	(spu_enumerate_spu_ids): Remove.
	(linux_nat_target::xfer_partial): Remove support for TARGET_OBJECT_SPU.
	* linux-tdep.c (-linux_spu_make_corefile_notes): Remove.
	(linux_make_corefile_notes): No longer call it.

	* regcache.c (cooked_read_test): Remove bfd_arch_spu special case.
	(cooked_write_test): Likewise.

gdb/doc/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* doc/gdb.texinfo (Remote Configuration): Remove documentation for
	qXfer:spu:read and qXfer:spu:write.
	(General Query Packets): Likewise.
	(Cell Broadband Engine SPU architecture): Remove subsection.

gdb/gdbserver/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* configure.srv (ipa_ppc_linux_regobj): Remove powerpc-cell32l-ipa.o
	and powerpc-cell64l-ipa.o.
	(powerpc*-*-linux*): Remove powerpc-cell32l.o and powerpc-cell64l.o
	from srv_regobj.  Remove rs6000/powerpc-cell32l.xml and
	rs6000/powerpc-cell64l.xml from srv_xmlfiles.
	(spu*-*-*): Remove.

	* spu-low.c: Remove file.

	* linux-ppc-low.c (INSTR_SC, NR_spu_run): Remove.
	(parse_spufs_run): Remove.
	(ppc_get_pc): Remove Cell/B.E. support.
	(ppc_set_pc): Likewise.
	(ppc_breakpoint_at): Likewise.
	(ppc_arch_setup): Likewise.
	(ppc_get_ipa_tdesc_idx): Do not handle tdesc_powerpc_cell64l or
	tdesc_powerpc_cell32l.
	(initialize_low_arch): Do not call init_registers_powerpc_cell64l
	or init_registers_powerpc_cell32l.
	* linux-ppc-ipa.c (get_ipa_tdesc): Do not handle PPC_TDESC_CELL.
	(initialize_low_tracepoint): Do not call init_registers_powerpc_cell64l
	or init_registers_powerpc_cell32l.
	* linux-ppc-tdesc-init.h (PPC_TDESC_CELL): Mark as unused.
	(init_registers_powerpc_cell32l): Remove prototype.
	(init_registers_powerpc_cell64l): Likewise.

	* target.h (struct target_ops): Remove qxfer_spu member.
	* server.c (handle_qxfer_spu): Remove.
	(qxfer_packets): Remove entry for "spu".
	(handle_query): No longer support qXfer:spu:read or qXfer:spu:write.
	* linux-low.c (SPUFS_MAGIC): Remove.
	(spu_enumerate_spu_ids): Remove.
	(linux_qxfer_spu): Remove.
	(linux_target_ops): Remove qxfer_spu member.
	* lynx-low.c (lynx_target_ops): Remove qxfer_spu member.
	* nto-low.c (nto_target_ops): Remove qxfer_spu member.
	* win32-low.c (win32_target_ops): Remove qxfer_spu member.

gdb/testsuite/ChangeLog
2019-09-20  Ulrich Weigand  <uweigand@de.ibm.com>

	* gdb.arch/spu-info.exp: Remove file.
	* gdb.arch/spu-info.c: Remove file.
	* gdb.arch/spu-ls.exp: Remove file.
	* gdb.arch/spu-ls.c: Remove file.

	* gdb.asm/asm-source.exp: Remove support for spu*-*-*.
	* gdb.asm/spu.inc: Remove file.

	* gdb.base/dump.exp: Remove support for spu*-*-*.
	* gdb.base/stack-checking.exp: Likewise.
	* gdb.base/overlays.exp: Likewise.
	* gdb.base/ovlymgr.c: Likewise.
	* gdb.base/spu.ld: Remove file.

	* gdb.cp/bs15503.exp: Remove support for spu*-*-*.
	* gdb.cp/cpexprs.exp: Likewise.
	* gdb.cp/exception.exp: Likewise.
	* gdb.cp/gdb2495.exp: Likewise.
	* gdb.cp/mb-templates.exp: Likewise.
	* gdb.cp/pr9167.exp: Likewise.
	* gdb.cp/userdef.exp: Likewise.

	* gdb.xml/tdesc-regs.exp: Remove support for spu*-*-*.

	* gdb.cell: Remove directory.
	* lib/cell.exp: Remove file.
2019-09-20 23:06:57 +02:00
Thomas Schwinge 6c6ef69fb4 [gdb, hurd] Repair build after "Share fork_inferior et al with gdbserver" changes
..., that is commit 2090129c36 causing:

    [...]/gdb/gnu-nat.c: In function 'void gnu_ptrace_me()':
    [...]/gdb/gnu-nat.c:2133:5: error: 'trace_start_error_with_name' was not declared in this scope
         trace_start_error_with_name ("ptrace");
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    [...]/gdb/gnu-nat.c:2133:5: note: suggested alternative: 'throw_perror_with_name'
         trace_start_error_with_name ("ptrace");
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
         throw_perror_with_name
    [...]/gdb/gnu-nat.c: In function 'void gnu_create_inferior(target_ops*, const char*, const string&, char**, int)':
    [...]/gdb/gnu-nat.c:2147:9: error: 'fork_inferior' was not declared in this scope
       pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me,
             ^~~~~~~~~~~~~
    [...]/gdb/gnu-nat.c:2147:9: note: suggested alternative: 'exit_inferior'
       pid = fork_inferior (exec_file, allargs, env, gnu_ptrace_me,
             ^~~~~~~~~~~~~
             exit_inferior
    [...]/gdb/gnu-nat.c:2174:30: error: 'START_INFERIOR_TRAPS_EXPECTED' was not declared in this scope
       gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    /usr/bin/ld: gnu-nat.o: in function `gnu_ptrace_me()':
    [...]/gdb/gnu-nat.c:2134: undefined reference to `trace_start_error_with_name(char const*)'
    /usr/bin/ld: gnu-nat.o: in function `gnu_create_inferior(target_ops*, char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, int)':
    [...]/gdb/gnu-nat.c:2148: undefined reference to `fork_inferior(char const*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))'
    /usr/bin/ld: fork-child.o: in function `gdb_startup_inferior(int, int)':
    [...]/gdb/fork-child.c:136: undefined reference to `startup_inferior(int, int, target_waitstatus*, ptid_t*)'
    collect2: error: ld returned 1 exit status

	gdb/
	* configure.nat [gdb_host == i386gnu] (NATDEPFILES): Add
	'nat/fork-inferior.o'.
	* gnu-nat.c: #include "nat/fork-inferior.h".
2019-02-14 16:36:05 +01:00
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Tom Tromey 6987262214 Build gdb "nat" files in subdirectory
This moves the various "nat" object files into the nat/ subdirectory.
This allows for the removal of a pattern rule from the gdb Makefile,
which is a small cleanup.

I made the configure.nat change in a (semi-) automated way, hopefully
meaning that it is more likely to be correct than had I done it by
hand.

Eventually I would like for the various configure scripts to only
mention source files, and let the Makefile compute the object file
names.

gdb/ChangeLog
2018-12-27  Tom Tromey  <tom@tromey.com>

	* configure.nat (NATDEPFILES): Use nat/ prefix.
	* Makefile.in (CONFIG_SRC_SUBDIR): Add nat.
	(%.o: ${srcdir}/nat/%.c): Remove rule.
	(INIT_FILES): Do not filter out NATDEPFILES.
2018-12-27 13:15:31 -07:00
John Baldwin 47db57fd4e Remove empty nm-fbsd.h header for FreeBSD/i386 native target.
gdb/ChangeLog:

	* config/i386/nm-fbsd.h: Remove file.
	* Makefile.in (HFILES_NO_SRCDIR): Remove config/i386/nm-fbsd.h.
	* configure.nat: Remove NAT_FILE for FreeBSD/i386.
2018-12-27 11:42:32 -08:00
John Baldwin 74792ff782 Add native target for FreeBSD/riscv.
gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add riscv-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/riscv native configuration.
	* configure.host: Add riscv*-*-freebsd*.
	* configure.nat: Likewise.
	* riscv-fbsd-nat.c: New file.

gdb/doc/ChangeLog:

	* gdb.texinfo (Contributors): Add SRI International and University
	of Cambridge for FreeBSD/riscv.
2018-10-08 14:47:34 -07:00
Rainer Orth 8674be7924 Fold i386-v4-nat.c into i386-sol2-nat.c
I've been carrying around the following patch for some time.  I noticed
that both i386-sol2-nat.c and i386-v4-nat.c are Solaris-only now and it
seems confusing to carry both around.

So this patch merges i386-v4-nat.c into i386-sol2-nat.c, simplifying it
in a couple of places, like removing checks for macros that are always
defined.

Tested on 64-bit Solaris 11.5/x86 (amd64-pc-solaris2.11) and 32-bit
Solaris 11.3/x86 (i386-pc-solaris2.11) half a year ago.

	* i386-v4-nat.c (regmap, supply_gregset, fill_gregset)
	(supply_fpregset, fill_fpregset): Move ...
	* i386-sol2-nat.c [PR_MODEL_NATIVE != PR_MODEL_LP64]: ... here.
	Remove HAVE_GREGSET_T, HAVE_FPREGET_T guards.
	Remove references to ioctl-based procfs.
	Include <sys/reg.h>.
	Remove PR_MODEL_NATIVE guards.
	* configure.nat <sol2, i386> (NATDEPFILES): Remove i386-v4-nat.o.
	* Makefile.in (ALLDEPFILES): Remove i386-v4-nat.c.
2018-09-20 10:10:07 +02:00
Jim Wilson 52a187f8e7 RISC-V: Add configure support for riscv*-linux*.
This adds the target and native configure support, and the NEWS entries for
the new target and native configurations.

	gdb/
	* Makefile.in (ALL_TARGET_OBS): Add riscv-linux-tdep.c.
	(ALLDEPFILES): Add riscv-linux-nat.c, and riscv-linux-tdep.c.
	* NEWS: Mention new GNU/Linux RISC-V target.
	* configure.host: Add riscv*-*-linux*.
	* configure.nat: Add riscv*.
	* configure.tgt: Add riscv*-*-linux*.
2018-08-09 13:37:45 -07:00
Alan Hayward 122394f147 Function for reading the Aarch64 SVE vector length
Returns 0 for systems without SVE support.

Note the defines taken from Linux kernel headers
in aarch64-sve-linux-ptrace.h.

gdb/
	* Makefile.in: Add new header.
	* gdb/arch/aarch64.h (sve_vg_from_vl): New macro.
	(sve_vl_from_vg): Likewise.
	(sve_vq_from_vl): Likewise.
	(sve_vl_from_vq): Likewise.
	(sve_vq_from_vg): Likewise.
	(sve_vg_from_vq): Likewise.
	* configure.nat: Add new c file.
	* nat/aarch64-sve-linux-ptrace.c: New file.
	* nat/aarch64-sve-linux-ptrace.h: New file.

gdbserver/
	* configure.srv: Add new c/h file.
2018-05-31 14:36:48 +01:00
Pedro Franco de Carvalho 2e077f5e67 [PowerPC] Consolidate wordsize getter between native and gdbserver
This patch moves the native target wordsize getter for ppc linux to
nat/ so that it can be used to simplify ppc_arch_setup in
gdbserver. The ptrace call used to get MSR for this is ultimately the
same as before, but it is no longer necessary to create a temporary
regcache to call fetch_inferior_registers.

gdb/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* configure.nat <linux powerpc>: Add ppc-linux.o to NATDEPFILES.
	* ppc-linux-nat.c (ppc_linux_target_wordsize): Move to
	nat/ppc-linux.c.
	(ppc_linux_nat_target::auxv_parse): Get thread id tid. Call
	ppc_linux_target_wordsize with tid.
	(ppc_linux_nat_target::read_description): Call ppc_linux_target
	wordsize with tid.
	* nat/ppc-linux.c: Include nat/gdb_ptrace.h.
	(ppc64_64bit_inferior_p): Add static and inline specifiers.
	(ppc_linux_target_wordsize): Move here from ppc-linux-nat.c. Add
	tid parameter. Remove static specifier.
	* nat/ppc-linux.h (ppc64_64bit_inferior_p): Remove declaration.
	(ppc_linux_target_wordsize): New declaration.

gdb/gdbserver/ChangeLog:
2018-05-22  Pedro Franco de Carvalho  <pedromfc@linux.vnet.ibm.com>

	* linux-ppc-low.c (ppc_arch_setup): Remove code for getting the
	wordsize of the inferior. Call ppc_linux_target_wordsize.
2018-05-22 11:52:02 -03:00
Pedro Alves 6798487f5b Make inf_ptrace_trad Linux-only, move to separate file
There are only two inf_ptrace_trad_target users, MIPS GNU/Linux and
Alpha GNU/Linux.  They both call it via linux_trad_target.

Move this code out of inf-ptrace.c to a GNU/Linux-specific new file.

Making this code be GNU/Linux-specific simplifies C++ification of
target_ops, because we can make the trad target inherit linux_nat
instead of inheriting inf_ptrace.  That'll be visible in a later patch.

Note this makes linux_target_install_ops an extern function, but that
is temporary -- the function will disappear once target_ops is made a
C++ class with virtual methods, later in the series.  Also, I did not
rename the functions in the new file for a similar reason.  They'll be
renamed again anyway in a couple of patches.

gdb/ChangeLog:
2018-05-02  Pedro Alves  <palves@redhat.com>

	* alpha-linux-nat.c: Include "linux-nat-trad.h" instead of
	"linux-nat.h".
	* configure.nat (alpha-linux, linux-mips): Add linux-nat-trad.o.
	* inf-ptrace.c (inf_ptrace_register_u_offset)
	(inf_ptrace_fetch_register, inf_ptrace_fetch_registers)
	(inf_ptrace_store_register, inf_ptrace_store_registers)
	(inf_ptrace_trad_target): Move to ...
	* linux-nat-trad.c: ... this new file.
	* linux-nat-trad.h: New file.
	* linux-nat.c (linux_target_install_ops): Make extern.
	(linux_trad_target): Delete.
	* linux-nat.h (linux_trad_target): Delete declaration.
	(linux_target_install_ops): Declare.
	* mips-linux-nat.c: Include "linux-nat-trad.h" instead of
	"linux-nat.h".
2018-05-03 00:47:32 +01:00
Pedro Alves a2a79012fe gdb: Remove OpenBSD/m88k support
Support for m88k was fully removed from bfd, which broke gdb
--enable-targets=all builds:

  > gdb/m88k-tdep.c: In function void _initialize_m88k_tdep():
  > gdb/m88k-tdep.c:867:21: error: bfd_arch_m88k was not declared in this scope
  >    gdbarch_register (bfd_arch_m88k, m88k_gdbarch_init, NULL);

There's no point in keeping GDB support for OpenBSD/m88k with no bfd
support, so this commit simply removes the port.

gdb/ChangeLog:
2018-04-16  Pedro Alves  <palves@redhat.com>

	* MAINTAINERS: Remove m88k.
	* Makefile.in (ALL_TARGET_OBS): Remove m88k-tdep.o.
	(HFILES_NO_SRCDIR): Remove m88k-tdep.h.
	(ALLDEPFILES): Remove m88k-bsd-nat.c and m88k-tdep.c.
	* NEWS: Mention that support for OpenBSD/m88k was removed.
	* configure.host (m88*-*-*): Remove support.
	* configure.nat (m88k-*-*): Remove support.
	* configure.tgt (m88*-*-openbsd*): Remove.
	* m88k-bsd-nat.c, m88k-tdep.c, m88k-tdep.h: Delete.
2018-04-16 13:16:22 +01:00
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Ulrich Weigand d7fcdff980 [spu] Fix spu-linux native build
Add missing file to NATDEPFILES.

gdb/ChangeLog:
2017-11-24  Ulrich Weigand  <uweigand@de.ibm.com>

	* configure.nat <spu-linux>: Add fork-inferior.o to NATDEPFILES.
2017-11-24 22:03:28 +01:00
John Baldwin 4f9d99066e Add native target for FreeBSD/arm.
gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add arm-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/arm native configuration.
	* configure.host: Add arm*-*-freebsd*.
	* configure.nat: Likewise.
	* arm-fbsd-nat.c: New file.
2017-10-11 11:16:34 -07:00
Rainer Orth 281c444773 Remove support for Solaris < 10 (PR gdb/22185)
Given that GCC has obsoleted/removed support for Solaris 9 in GCC 4.9/5 in 2013:

    https://gcc.gnu.org/gcc-4.9/changes.html
    https://gcc.gnu.org/ml/gcc-patches/2013-05/msg00728.html

and the last gdb version that can be compiled with gcc 4.9 is 7.12.1 only when
configured with --disable-build-with-cxx, it's time to obsolete/remove support
for Solaris < 10.

This patch does this, simplifying configure.nat along the way (only a single
sol2 configuration with variants for i386 and sparc).

Some configure checks for older Solaris versions can go, too, and the check
for libthread_db.so.1 removed:

* Since Solaris 10, dlopen has moved to libc and libdl.so is just a
  filter on ld.so.1, so no need to check.

* $RDYNAMIC is already handled above (and is a no-op with Solaris ld
  anyway).

Both proc-service.c and sol-thread.c lose support for (Solaris-only)
PROC_SERVICE_IS_OLD.

The attached revised patch has been tested on sparcv9-sun-solaris2.10,
sparcv9-sun-solaris2.11.4, amd64-pc-solaris2.10, amd64-pc-solaris2.11.4,
and x86_64-pc-linux-gnu.

I've also started an i386-pc-solaris2.9 build to check that it really
stops as expected.

	PR gdb/22185
	* configure.host <*-*-solaris2.[01], *-*-solaris2.[2-9]*>: Mark as
	obsolete.
	Use gdb_host sol2 for i[34567]86-*-solaris2*, x86_64-*-solaris2*.
	Remove i386sol2 support.
	* configure.nat <i386sol2>: Remove.
	<sol2-64>: Fold into ...
	<sol2>: ... this.
	Move common settings to default section.
	Add sol-thread.o.
	* configure.tgt <i[34567]86-*-solaris2.1[0-9]*,
	x86_64-*-solaris2.1[0-9]*>: Rename to ...
	<i[34567]86-*-solaris2*, x86_64-*-solaris2*>: ... this.
	<i[34567]86-*-solaris*>: Remove.
	<sparc-*-solaris2.[0-6], sparc-*-solaris2.[0-6].*>: Remove.

	* configure.ac: Remove wctype in libw check.
	(_MSE_INT_H): Don't define on Solaris 7-9.
	<solaris*>: Remove libthread_db.so.1 check.
	* configure: Regenerate.
	* config.in: Regenerate.

	* proc-service.c: Remove PROC_SERVICE_IS_OLD handling.
	(gdb_ps_prochandle_t, gdb_ps_read_buf_t, gdb_ps_write_buf_t)
	(gdb_ps_size_t): Remove.
	Use base types in users.
	* sol-thread.c: Likewise, also for gdb_ps_addr_t.

	* NEWS (Changes since GDB 8.0): Document Solaris 2.0-9 removal.
2017-09-26 15:19:10 +02:00
Rainer Orth 4fa7574eec Fix gdb 8.1 Solaris compilation
I just tried to compile gdb trunk on Solaris 11.4 (formerly 12), and
failed for a couple of reasons:

*

In file included from /usr/include/python2.7/Python.h:128:0,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/python-internal.h:94,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.h:23,
                 from /vol/src/gnu/gdb/gdb/dist/gdb/python/py-instruction.c:21:
/usr/include/python2.7/ceval.h:67:0: error: ignoring #pragma no_inline  [-Werror=unknown-pragmas]
 #pragma no_inline(PyEval_EvalFrameEx)
 ^

  New in Solaris 11.4: <python2.7/ceval.h> uses a Studio-only #pragma.
  I've disabled the warning in warnings.m4.

*

/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c: In function ‘int pipe_open(serial*, const char*)’:
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:9: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
         ^
/vol/src/gnu/gdb/gdb/dist/gdb/ser-pipe.c:77:16: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   pid = vfork ();
                ^

  Since Solaris 11, vfork () is marked deprecated in <unistd.h>.

  cf. vfork(2):

       The  vfork()  and vforkx() functions are deprecated. Their sole legiti-
       mate use as a prelude to an immediate call to a function from the  exec
       family can be achieved safely by posix_spawn(3C) or posix_spawnp(3C).

  Again, I've disabled the warning.

*

/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c: In function ‘void shell_escape(const char*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:14: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
              ^
/vol/src/gnu/gdb/gdb/dist/gdb/cli/cli-cmds.c:750:21: error: ‘pid_t vfork()’ is deprecated (declared at /usr/include/unistd.h:659) [-Werror=deprecated-declarations]
   if ((pid = vfork ()) == 0)
                     ^

  Same problem.

*

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_init_inferior(target_ops*, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4380:30: error: ‘START_INFERIOR_TRAPS_EXPECTED’ was not declared in this scope
   gdb_startup_inferior (pid, START_INFERIOR_TRAPS_EXPECTED);
                              ^

  defined in nat/fork-inferior.h, need to include that header

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_create_inferior(target_ops*, const char*, const string&, char**, int)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:4605:38: error: ‘fork_inferior’ was not declared in this scope
          NULL, NULL, shell_file, NULL);
                                      ^

  likewise

/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c: In function ‘void procfs_info_proc(target_ops*, const char*, info_proc_what)’:
/vol/src/gnu/gdb/gdb/dist/gdb/procfs.c:5124:20: error: ‘argv’ was not declared in this scope
   for (char *arg : argv)
                    ^

  Typo, should be built_argv instead!

*

Undefined                       first referenced
 symbol                             in file
fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) procfs.o
startup_inferior(int, int, target_waitstatus*, ptid_t*) fork-child.o
ld: fatal: symbol referencing errors
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:2249: gdb] Error 1

  Need to add fork-inferior.o to NATDEPFILES.

With the changes below, I can build gdb on sparcv9-sun-solaris2.11 and
amd64-pc-solaris2.11 and a simple smoke test (gdb/gdb gdb/gdb) works.
2017-09-22 10:42:45 +02:00
Kamil Rytarowski 28ad437d7a Define HAVE_NATIVE_GCORE_HOST on NetBSD
NetBSD ships with gcore(1) againg since the version 2.0.
This tool is functional and actively maintained.

gdb/ChangeLog
2017-09-06  Kamil Rytarowski  <n54@gmx.com>

	* configure.nat: Define HAVE_NATIVE_GCORE_HOST on NetBSD.
2017-09-06 18:40:29 +02:00
John Baldwin 351787dd4c Add native target for FreeBSD/aarch64.
gdb/ChangeLog:

	* Makefile.in (ALLDEPFILES): Add mips-fbsd-nat.c.
	* NEWS: Mention new FreeBSD/mips native configuration.
	* configure.host: Add aarch64*-*-freebsd*.
	* configure.nat: Likewise.
	* aarch64-fbsd-nat.c: New file.
2017-09-06 09:42:08 -07:00
John Baldwin a379bfd00e Enable support for x86 debug registers on NetBSD.
NetBSD recently added PT_GETDBREGS and PT_SETDBREGS ptrace operations
that match the existing ones supported by x86-bsd-nat.c.  NetBSD's
headers do not provide the DBREG_DRX helper macro, so define a local
version in x86-bsd-nat.c.  In addition, add the x86-nat.o and x86-dregs.o
object files to the native NetBSD x86 build targets.

gdb/ChangeLog:

	* configure.nat: Add "x86-nat.o x86-dregs.o" for NetBSD/amd64 and
	NetBSD/i386.
	* x86-bsd-nat.c [!DBREG_DRX && __NetBSD__]: Define DBREG_DRX.
2017-09-04 19:34:48 -07:00
John Baldwin b9c0e1b40e Fix two NetBSD-specific typos in the configure.nat conversion.
- Add the '-lkvm' library requirement for NetBSD/sparc64.
- Fix spelling of 'nbsdelf' host.

gdb/Changelog:

	* configure.nat: Add "-lkvm" for NetBSD/sparc64 and fix typo.
2017-07-25 09:40:44 -07:00
Simon Marchi 848d907446 darwin: Add fork-inferior.o to NATDEPFILES
I happened to be build-testing on macOS and found this:

  Undefined symbols for architecture x86_64:

    "fork_inferior(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))", referenced from:

        darwin_create_inferior(target_ops*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, int) in darwin-nat.o

    "startup_inferior(int, int, target_waitstatus*, ptid_t*)", referenced from:

        gdb_startup_inferior(int, int) in fork-child.o

    "trace_start_error(char const*, ...)", referenced from:

        darwin_ptrace_me() in darwin-nat.o

    "trace_start_error_with_name(char const*)", referenced from:

        darwin_ptrace_me() in darwin-nat.o

  ld: symbol(s) not found for architecture x86_64

  clang: error: linker command failed with exit code 1 (use -v to see invocation)

Adding fork-inferior.o fixes it.  I factored out the Darwin bits that
are no architecture-specific in the section meant for that at the top.

I only built-tested this using Travis-CI, since I don't have access to
this platform.

gdb/ChangeLog:

	* configure.nat: Factor out Darwin bits that are not
	architecture-specific.  Add fork-inferior.o.
2017-06-13 21:14:35 +02:00
Simon Marchi 3b912944f4 aix: Add fork-inferior.o to NATDEPFILES
Trying to build on AIX gives:

ld: 0711-317 ERROR: Undefined symbol: .trace_start_error_with_name(char const*)
ld: 0711-317 ERROR: Undefined symbol: .fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))
ld: 0711-317 ERROR: Undefined symbol: .startup_inferior(int, int, target_waitstatus*, ptid_t*)

Including fork-inferior.o in the build should help.  I also factored out
the AIX bits that are not architecture-specific to be consistent with the other
OSes.

gdb/ChangeLog:

	* configure.nat: Factor out AIX bits that are not
	architecture-specific.  Add fork-inferior.o.
2017-06-13 21:14:25 +02:00
Sergio Durigan Junior 2090129c36 Share fork_inferior et al with gdbserver
This is the most important (and the biggest, sorry) patch of the
series.  It moves fork_inferior from gdb/fork-child.c to
nat/fork-inferior.c and makes all the necessary adjustments to both
GDB and gdbserver to make sure everything works OK.

There is no "most important change" with this patch; all changes are
made in a progressive way, making sure that gdbserver had the
necessary features while not breaking GDB at the same time.

I decided to go ahead and implement a partial support for starting the
inferior with a shell on gdbserver, although the full feature comes in
the next patch.  The user won't have the option to disable the
startup-with-shell, and also won't be able to change which shell
gdbserver will use (other than setting the $SHELL environment
variable, that is).

Everything is working as expected, and no regressions were present
during the tests.

gdb/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (HFILES_NO_SRCDIR): Add "common/common-inferior.h"
	and "nat/fork-inferior.h".
	* common/common-inferior.h: New file, with contents from
	"gdb/inferior.h".
	* commom/common-utils.c: Include "common-utils.h".
	(stringify_argv): New function.
	* common/common-utils.h (stringify_argv): New prototype.
	* configure.nat: Add "fork-inferior.o" as a dependency for
	"*linux*", "fbsd*" and "nbsd*" hosts.
	* corefile.c (get_exec_file): Update comment.
	* darwin-nat.c (darwin_ptrace_him): Call "gdb_startup_inferior"
	instead of "startup_inferior".
	(darwin_create_inferior): Call "add_thread_silent" after
	"fork_inferior".
	* fork-child.c: Cleanup unnecessary includes.
	(SHELL_FILE): Move to "common/common-fork-child.c".
	(environ): Likewise.
	(exec_wrapper): Initialize.
	(get_exec_wrapper): New function.
	(breakup_args): Move to "common/common-fork-child.c"; rename to
	"breakup_args_for_exec".
	(escape_bang_in_quoted_argument): Move to
	"common/common-fork-child.c".
	(saved_ui): New variable.
	(prefork_hook): New function.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(gdb_startup_inferior): Likewise.
	(fork_inferior): Move to "common/common-fork-child.c".  Update
	function to support gdbserver.
	(startup_inferior): Likewise.
	* gdbcore.h (get_exec_file): Remove declaration.
	* gnu-nat.c (gnu_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inf-ptrace.c: Include "nat/fork-inferior.h" and "utils.h".
	(inf_ptrace_create_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* inferior.h: Include "common-inferior.h".
	(trace_start_error): Move to "common/common-utils.h".
	(trace_start_error_with_name): Likewise.
	(fork_inferior): Move prototype to "nat/fork-inferior.h".
	(startup_inferior): Likewise.
	(gdb_startup_inferior): New prototype.
	* nat/fork-inferior.c: New file, with contents from "fork-child.c".
	* nat/fork-inferior.h: New file.
	* procfs.c (procfs_init_inferior): Call "gdb_startup_inferior"
	instead of "startup_inferior".  Call "add_thread_silent" after
	"fork_inferior".
	* target.h (target_terminal_init): Move prototype to
	"target/target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target/target.h (target_terminal_init): New prototype, moved
	from "target.h".
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* utils.c (gdb_flush_out_err): New function.

gdb/gdbserver/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>
	    Pedro Alves  <palves@redhat.com>

	* Makefile.in (SFILES): Add "nat/fork-inferior.o".
	* configure: Regenerate.
	* configure.srv (srv_linux_obj): Add "fork-child.o" and
	"fork-inferior.o".
	(i[34567]86-*-lynxos*): Likewise.
	(spu*-*-*): Likewise.
	* fork-child.c: New file.
	* linux-low.c: Include "common-inferior.h", "nat/fork-inferior.h"
	and "environ.h".
	(linux_ptrace_fun): New function.
	(linux_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	(linux_request_interrupt): Delete "signal_pid".
	* lynx-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(lynx_ptrace_fun): New function.
	(lynx_create_inferior): Adjust function prototype to reflect
	change on "target.h".  Adjust function code to use
	"fork_inferior".
	* nto-low.c (nto_create_inferior): Adjust function prototype and
	code to reflect change on "target.h".  Update comments.
	* server.c: Include "common-inferior.h", "nat/fork-inferior.h",
	"common-terminal.h" and "environ.h".
	(terminal_fd): Moved to fork-child.c.
	(old_foreground_pgrp): Likewise.
	(restore_old_foreground_pgrp): Likewise.
	(last_status): Make it global.
	(last_ptid): Likewise.
	(our_environ): New variable.
	(startup_with_shell): Likewise.
	(program_name): Likewise.
	(program_argv): Rename to...
	(program_args): ...this.
	(wrapper_argv): New variable.
	(start_inferior): Delete function.
	(get_exec_wrapper): New function.
	(get_exec_file): Likewise.
	(get_environ): Likewise.
	(prefork_hook): Likewise.
	(post_fork_inferior): Likewise.
	(postfork_hook): Likewise.
	(postfork_child_hook): Likewise.
	(handle_v_run): Update code to deal with arguments coming from the
	remote host.  Update calls from "start_inferior" to
	"create_inferior".
	(captured_main): Likewise.  Initialize environment variable.  Call
	"have_job_control".
	* server.h (post_fork_inferior): New prototype.
	(get_environ): Likewise.
	(last_status): Declare.
	(last_ptid): Likewise.
	(signal_pid): Likewise.
	* spu-low.c: Include "common-inferior.h" and "nat/fork-inferior.h".
	(spu_ptrace_fun): New function.
	(spu_create_inferior): Adjust function prototype to reflect change
	on "target.h".  Adjust function code to use "fork_inferior".
	* target.c (target_terminal_init): New function.
	(target_terminal_inferior): Likewise.
	(target_terminal_ours): Likewise.
	* target.h: Include <vector>.
	(struct target_ops) <create_inferior>: Update prototype.
	(create_inferior): Update macro.
	* utils.c (gdb_flush_out_err): New function.
	* win32-low.c (win32_create_inferior): Adjust function prototype
	and code to reflect change on "target.h".

gdb/testsuite/ChangeLog:
2017-06-07  Sergio Durigan Junior  <sergiodj@redhat.com>

	* gdb.server/non-existing-program.exp: Update regex in order to
	reflect the fact that gdbserver is now using fork_inferior (with a
	shell) to startup the inferior.
2017-06-07 19:56:09 -04:00
Pedro Alves 2b351b19ef nat_extra_makefile_frag -> nat_makefile_frag
gdb/ChangeLog:
2017-05-17  Pedro Alves  <palves@redhat.com>

	* Makefile.in (nat_extra_makefile_frag): Rename to ...
	(nat_makefile_frag): ... this.  All references updated.
	* configure.ac: Likewise.
	* configure.nat: Likewise.  Enhance comments.
	* configure: Regenerate.
2017-05-17 13:56:19 +01:00
Sergio Durigan Junior e50f25ecdb Rearrange gdb/configure.nat to make it simpler and less redundant
The previous commit introduced gdb/configure.nat, but it was just a
copy-and-past (with the necessary adjustments) from the files under
gdb/config/.  We can do better than that.

Instead of using one big 'case' statement that matches the
${gdb_host_cpu} and then match each ${gdb_host}, it is possible to
remove a lof of redundancy by matching the most common ${gdb_host}'s
first, setting the common variables for each, and then proceed to
matching specific ${gdb_host}'s and ${gdb_host_cpu}'s.  In other
words, reverse the order of the 'case's and take advantage of the fact
that a lot of parameters are the same for each host.

This commit was tested on x86_64 without regressions.

gdb/ChangeLog:
2017-05-06  Sergio Durigan Junior  <sergiodj@redhat.com>

 	* configure.nat: Rearrange 'case' statements to match
	host before cpu.
2017-05-06 10:10:55 -04:00
Sergio Durigan Junior 21ea5acdd1 Introduce "gdb/configure.nat" (and delete "gdb/config/*/*.mh" files)
Due to my ongoing work to make it possible for gdbserver to start the
inferior using the shell, I had to share the fork_inferior function
under the "nat/" directory.  In order to do that, I created a new file
and put the function there; however, this meant that I now had to
update some of the *.mh files (under "gdb/config") and add the new
file as a dependency to be built natively.  Bleh...

After talking a bit to Pedro about this, the idea came up to write a
new "gdb/configure.nat" file, a la "gdb/configure.tgt", which would
concentrate all of the native settings for each host/system.  I
decided to tackle this issue.

The patch is simple.  All of the previous Makefile variables that were
being declared inside the *.mh files are now inside "gdb/Makefile.in",
and "gdb/configure" is responsible for AC_SUBST'ing them.  The
definitions of these variables were put inside "gdb/configure.nat", so
now they're shell variables.  For excerpts of Makefile code, one must
create a file under "gdb/config/${gdb_cpu_host}" and reference it on
the "nat_extra_makefile_frag" variable.

It should now be easier to update the native dependencies of hosts in
this single file.

This has been tested on x86_64 without regressions.

gdb/ChangeLog:
2017-05-06  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile.in: Remove "@host_makefile_frag@".  Add variables
	NAT_FILE, NATDEPFILES, NAT_CDEPS, LOADLIBES, MH_CFLAGS, XM_CLIBS,
	NAT_GENERATED_FILES, HAVE_NATIVE_GCORE_HOST.  Add
	"@nat_extra_makefile_frag@".
	(Makefile): Remove dependency on "@frags@".
	($(GNULIB_BUILDDIR)/Makefile): Likewise.
	(data-directory/Makefile): Likewise.
	* config/aarch64/linux.mh: Deleted; moved contents to
	"gdb/configure.nat".
	* config/alpha/alpha-linux.mh: Likewise.
	* config/alpha/nbsd.mh: Likewise.
	* config/arm/linux.mh: Likewise.
	* config/arm/nbsdelf.mh: Likewise.
	* config/i386/cygwin.mh: Likewise.
	* config/i386/cygwin64.mh: Likewise.
	* config/i386/darwin.mh: Likewise.
	* config/i386/fbsd.mh: Likewise.
	* config/i386/fbsd64.mh: Likewise.
	* config/i386/go32.mh: Likewise.
	* config/i386/i386gnu.mh: Likewise.
	* config/i386/i386sol2.mh: Likewise.
	* config/i386/linux.mh: Likewise.
	* config/i386/linux64.mh: Likewise.
	* config/i386/mingw.mh: Likewise.
	* config/i386/mingw64.mh: Likewise.
	* config/i386/nbsd64.mh: Likewise.
	* config/i386/nbsdelf.mh: Likewise.
	* config/i386/nto.mh: Likewise.
	* config/i386/obsd.mh: Likewise.
	* config/i386/obsd64.mh: Likewise.
	* config/i386/sol2-64.mh: Likewise.
	* config/ia64/linux.mh: Likewise.
	* config/m32r/linux.mh: Likewise.
	* config/m68k/linux.mh: Likewise.
	* config/m68k/nbsdelf.mh: Likewise.
	* config/m68k/obsd.mh: Likewise.
	* config/m88k/obsd.mh: Likewise.
	* config/mips/fbsd.mh: Likewise.
	* config/mips/linux.mh: Likewise.
	* config/mips/nbsd.mh: Likewise.
	* config/mips/obsd64.mh: Likewise.
	* config/pa/linux.mh: Likewise.
	* config/pa/nbsd.mh: Likewise.
	* config/pa/obsd.mh: Likewise.
	* config/powerpc/aix.mh: Likewise.
	* config/powerpc/fbsd.mh: Likewise.
	* config/powerpc/linux.mh: Likewise.
	* config/powerpc/nbsd.mh: Likewise.
	* config/powerpc/obsd.mh: Likewise.
	* config/powerpc/ppc64-linux.mh: Likewise.
	* config/powerpc/spu-linux.mh: Likewise.
	* config/s390/linux.mh: Likewise.
	* config/sh/nbsd.mh: Likewise.
	* config/sparc/fbsd.mh: Likewise.
	* config/sparc/linux.mh: Likewise.
	* config/sparc/linux64.mh: Likewise.
	* config/sparc/nbsd64.mh: Likewise.
	* config/sparc/nbsdelf.mh: Likewise.
	* config/sparc/obsd64.mh: Likewise.
	* config/sparc/sol2.mh: Likewise.
	* config/tilegx/linux.mh: Likewise.
	* config/vax/nbsdelf.mh: Likewise.
	* config/vax/obsd.mh: Likewise.
	* config/xtensa/linux.mh: Likewise.
	* config/i386/i386gnu.mn: New file, with excerpts from
	"config/i386/i386gnu.mh".
	* configure: Regenerate.
	* configure.ac: Rewrite code to use "gdb/configure.nat" instead of
	*.mh files under "gdb/config".
	* configure.nat: New file, with contents from the
	"gdb/config/*/*.mh" files.

gdb/doc/ChangeLog:
2017-05-06  Sergio Durigan Junior  <sergiodj@redhat.com>

	* Makefile: Remove "@host_makefile_frag@".
2017-05-06 10:09:35 -04:00