8d7493201c
This patch is part of the make-gdb-buildable-in-C++ effort. The idea is to change some calls to the xmalloc family of functions to calls to the equivalents in the XNEW family. This avoids adding an explicit cast, so it keeps the code a bit more readable. Some of them also map relatively well to a C++ equivalent (XNEW (struct foo) -> new foo), so it will be possible to do scripted replacements if needed. I only changed calls that were obviously allocating memory for one or multiple "objects". Allocation of variable sizes (such as strings or buffer handling) will be for later (and won't use XNEW). - xmalloc (sizeof (struct foo)) -> XNEW (struct foo) - xmalloc (num * sizeof (struct foo)) -> XNEWVEC (struct foo, num) - xcalloc (1, sizeof (struct foo)) -> XCNEW (struct foo) - xcalloc (num, sizeof (struct foo)) -> XCNEWVEC (struct foo, num) - xrealloc (p, num * sizeof (struct foo) -> XRESIZEVEC (struct foo, p, num) - obstack_alloc (ob, sizeof (struct foo)) -> XOBNEW (ob, struct foo) - obstack_alloc (ob, num * sizeof (struct foo)) -> XOBNEWVEC (ob, struct foo, num) - alloca (sizeof (struct foo)) -> XALLOCA (struct foo) - alloca (num * sizeof (struct foo)) -> XALLOCAVEC (struct foo, num) Some instances of xmalloc followed by memset to zero the buffer were replaced by XCNEW or XCNEWVEC. I regtested on x86-64, Ubuntu 14.04, but the patch touches many architecture-specific files. For those I'll have to rely on the buildbot or people complaining that I broke their gdb. gdb/ChangeLog: * aarch64-linux-nat.c (aarch64_add_process): Likewise. * aarch64-tdep.c (aarch64_gdbarch_init): Likewise. * ada-exp.y (write_ambiguous_var): Likewise. * ada-lang.c (resolve_subexp): Likewise. (user_select_syms): Likewise. (assign_aggregate): Likewise. (ada_evaluate_subexp): Likewise. (cache_symbol): Likewise. * addrmap.c (allocate_key): Likewise. (addrmap_create_mutable): Likewise. * aix-thread.c (sync_threadlists): Likewise. * alpha-tdep.c (alpha_push_dummy_call): Likewise. (alpha_gdbarch_init): Likewise. * amd64-windows-tdep.c (amd64_windows_push_arguments): Likewise. * arm-linux-nat.c (arm_linux_add_process): Likewise. * arm-linux-tdep.c (arm_linux_displaced_step_copy_insn): Likewise. * arm-tdep.c (push_stack_item): Likewise. (arm_displaced_step_copy_insn): Likewise. (arm_gdbarch_init): Likewise. (_initialize_arm_tdep): Likewise. * avr-tdep.c (push_stack_item): Likewise. * ax-general.c (new_agent_expr): Likewise. * block.c (block_initialize_namespace): Likewise. * breakpoint.c (alloc_counted_command_line): Likewise. (update_dprintf_command_list): Likewise. (parse_breakpoint_sals): Likewise. (decode_static_tracepoint_spec): Likewise. (until_break_command): Likewise. (clear_command): Likewise. (update_global_location_list): Likewise. (get_breakpoint_objfile_data) Likewise. * btrace.c (ftrace_new_function): Likewise. (btrace_set_insn_history): Likewise. (btrace_set_call_history): Likewise. * buildsym.c (add_symbol_to_list): Likewise. (record_pending_block): Likewise. (start_subfile): Likewise. (start_buildsym_compunit): Likewise. (push_subfile): Likewise. (end_symtab_get_static_block): Likewise. (buildsym_init): Likewise. * cli/cli-cmds.c (source_command): Likewise. * cli/cli-decode.c (add_cmd): Likewise. * cli/cli-script.c (build_command_line): Likewise. (setup_user_args): Likewise. (realloc_body_list): Likewise. (process_next_line): Likewise. (copy_command_lines): Likewise. * cli/cli-setshow.c (do_set_command): Likewise. * coff-pe-read.c (read_pe_exported_syms): Likewise. * coffread.c (coff_locate_sections): Likewise. (coff_symtab_read): Likewise. (coff_read_struct_type): Likewise. * common/cleanups.c (make_my_cleanup2): Likewise. * common/common-exceptions.c (throw_it): Likewise. * common/filestuff.c (make_cleanup_close): Likewise. * common/format.c (parse_format_string): Likewise. * common/queue.h (DEFINE_QUEUE_P): Likewise. * compile/compile-object-load.c (munmap_list_add): Likewise. (compile_object_load): Likewise. * compile/compile-object-run.c (compile_object_run): Likewise. * compile/compile.c (append_args): Likewise. * corefile.c (specify_exec_file_hook): Likewise. * cp-support.c (make_symbol_overload_list): Likewise. * cris-tdep.c (push_stack_item): Likewise. (cris_gdbarch_init): Likewise. * ctf.c (ctf_trace_file_writer_new): Likewise. * dbxread.c (init_header_files): Likewise. (add_new_header_file): Likewise. (init_bincl_list): Likewise. (dbx_end_psymtab): Likewise. (start_psymtab): Likewise. (dbx_end_psymtab): Likewise. * dcache.c (dcache_init): Likewise. * dictionary.c (dict_create_hashed): Likewise. (dict_create_hashed_expandable): Likewise. (dict_create_linear): Likewise. (dict_create_linear_expandable): Likewise. * dtrace-probe.c (dtrace_process_dof_probe): Likewise. * dummy-frame.c (register_dummy_frame_dtor): Likewise. * dwarf2-frame-tailcall.c (cache_new_ref1): Likewise. * dwarf2-frame.c (dwarf2_build_frame_info): Likewise. (decode_frame_entry_1): Likewise. * dwarf2expr.c (new_dwarf_expr_context): Likewise. * dwarf2loc.c (dwarf2_compile_expr_to_ax): Likewise. * dwarf2read.c (dwarf2_has_info): Likewise. (create_signatured_type_table_from_index): Likewise. (dwarf2_read_index): Likewise. (dw2_get_file_names_reader): Likewise. (create_all_type_units): Likewise. (read_cutu_die_from_dwo): Likewise. (init_tu_and_read_dwo_dies): Likewise. (init_cutu_and_read_dies): Likewise. (create_all_comp_units): Likewise. (queue_comp_unit): Likewise. (inherit_abstract_dies): Likewise. (read_call_site_scope): Likewise. (dwarf2_add_field): Likewise. (dwarf2_add_typedef): Likewise. (dwarf2_add_member_fn): Likewise. (attr_to_dynamic_prop): Likewise. (abbrev_table_alloc_abbrev): Likewise. (abbrev_table_read_table): Likewise. (add_include_dir): Likewise. (add_file_name): Likewise. (dwarf_decode_line_header): Likewise. (dwarf2_const_value_attr): Likewise. (dwarf_alloc_block): Likewise. (parse_macro_definition): Likewise. (set_die_type): Likewise. (write_psymtabs_to_index): Likewise. (create_cus_from_index): Likewise. (dwarf2_create_include_psymtab): Likewise. (process_psymtab_comp_unit_reader): Likewise. (build_type_psymtab_dependencies): Likewise. (read_comp_units_from_section): Likewise. (compute_compunit_symtab_includes): Likewise. (create_dwo_unit_in_dwp_v1): Likewise. (create_dwo_unit_in_dwp_v2): Likewise. (read_func_scope): Likewise. (process_structure_scope): Likewise. (mark_common_block_symbol_computed): Likewise. (load_partial_dies): Likewise. (dwarf2_symbol_mark_computed): Likewise. * elfread.c (elf_symfile_segments): Likewise. (elf_read_minimal_symbols): Likewise. * environ.c (make_environ): Likewise. * eval.c (evaluate_subexp_standard): Likewise. * event-loop.c (create_file_handler): Likewise. (create_async_signal_handler): Likewise. (create_async_event_handler): Likewise. (create_timer): Likewise. * exec.c (build_section_table): Likewise. * fbsd-nat.c (fbsd_remember_child): Likewise. * fork-child.c (fork_inferior): Likewise. * frv-tdep.c (new_variant): Likewise. * gdbarch.sh (gdbarch_alloc): Likewise. (append_name): Likewise. * gdbtypes.c (rank_function): Likewise. (copy_type_recursive): Likewise. (add_dyn_prop): Likewise. * gnu-nat.c (make_proc): Likewise. (make_inf): Likewise. (gnu_write_inferior): Likewise. * gnu-v3-abi.c (build_gdb_vtable_type): Likewise. (build_std_type_info_type): Likewise. * guile/scm-param.c (compute_enum_list): Likewise. * guile/scm-utils.c (gdbscm_parse_function_args): Likewise. * guile/scm-value.c (gdbscm_value_call): Likewise. * h8300-tdep.c (h8300_gdbarch_init): Likewise. * hppa-tdep.c (hppa_init_objfile_priv_data): Likewise. (read_unwind_info): Likewise. * ia64-tdep.c (ia64_gdbarch_init): Likewise. * infcall.c (dummy_frame_context_saver_setup): Likewise. (call_function_by_hand_dummy): Likewise. * infcmd.c (step_once): Likewise. (finish_forward): Likewise. (attach_command): Likewise. (notice_new_inferior): Likewise. * inferior.c (add_inferior_silent): Likewise. * infrun.c (add_displaced_stepping_state): Likewise. (save_infcall_control_state): Likewise. (save_inferior_ptid): Likewise. (_initialize_infrun): Likewise. * jit.c (bfd_open_from_target_memory): Likewise. (jit_gdbarch_data_init): Likewise. * language.c (add_language): Likewise. * linespec.c (decode_line_2): Likewise. * linux-nat.c (add_to_pid_list): Likewise. (add_initial_lwp): Likewise. * linux-thread-db.c (add_thread_db_info): Likewise. (record_thread): Likewise. (info_auto_load_libthread_db): Likewise. * m32c-tdep.c (m32c_gdbarch_init): Likewise. * m68hc11-tdep.c (m68hc11_gdbarch_init): Likewise. * m68k-tdep.c (m68k_gdbarch_init): Likewise. * m88k-tdep.c (m88k_analyze_prologue): Likewise. * macrocmd.c (macro_define_command): Likewise. * macroexp.c (gather_arguments): Likewise. * macroscope.c (sal_macro_scope): Likewise. * macrotab.c (new_macro_table): Likewise. * mdebugread.c (push_parse_stack): Likewise. (parse_partial_symbols): Likewise. (parse_symbol): Likewise. (psymtab_to_symtab_1): Likewise. (new_block): Likewise. (new_psymtab): Likewise. (mdebug_build_psymtabs): Likewise. (add_pending): Likewise. (elfmdebug_build_psymtabs): Likewise. * mep-tdep.c (mep_gdbarch_init): Likewise. * mi/mi-main.c (mi_execute_command): Likewise. * mi/mi-parse.c (mi_parse_argv): Likewise. * minidebug.c (lzma_open): Likewise. * minsyms.c (terminate_minimal_symbol_table): Likewise. * mips-linux-nat.c (mips_linux_insert_watchpoint): Likewise. * mips-tdep.c (mips_gdbarch_init): Likewise. * mn10300-tdep.c (mn10300_gdbarch_init): Likewise. * msp430-tdep.c (msp430_gdbarch_init): Likewise. * mt-tdep.c (mt_registers_info): Likewise. * nat/aarch64-linux.c (aarch64_linux_new_thread): Likewise. * nat/linux-btrace.c (linux_enable_bts): Likewise. (linux_enable_pt): Likewise. * nat/linux-osdata.c (linux_xfer_osdata_processes): Likewise. (linux_xfer_osdata_processgroups): Likewise. * nios2-tdep.c (nios2_gdbarch_init): Likewise. * nto-procfs.c (procfs_meminfo): Likewise. * objc-lang.c (start_msglist): Likewise. (selectors_info): Likewise. (classes_info): Likewise. (find_methods): Likewise. * objfiles.c (allocate_objfile): Likewise. (update_section_map): Likewise. * osabi.c (gdbarch_register_osabi): Likewise. (gdbarch_register_osabi_sniffer): Likewise. * parse.c (start_arglist): Likewise. * ppc-linux-nat.c (hwdebug_find_thread_points_by_tid): Likewise. (hwdebug_insert_point): Likewise. * printcmd.c (display_command): Likewise. (ui_printf): Likewise. * procfs.c (create_procinfo): Likewise. (load_syscalls): Likewise. (proc_get_LDT_entry): Likewise. (proc_update_threads): Likewise. * prologue-value.c (make_pv_area): Likewise. (pv_area_store): Likewise. * psymtab.c (extend_psymbol_list): Likewise. (init_psymbol_list): Likewise. (allocate_psymtab): Likewise. * python/py-inferior.c (add_thread_object): Likewise. * python/py-param.c (compute_enum_values): Likewise. * python/py-value.c (valpy_call): Likewise. * python/py-varobj.c (py_varobj_iter_next): Likewise. * python/python.c (ensure_python_env): Likewise. * record-btrace.c (record_btrace_start_replaying): Likewise. * record-full.c (record_full_reg_alloc): Likewise. (record_full_mem_alloc): Likewise. (record_full_end_alloc): Likewise. (record_full_core_xfer_partial): Likewise. * regcache.c (get_thread_arch_aspace_regcache): Likewise. * remote-fileio.c (remote_fileio_init_fd_map): Likewise. * remote-notif.c (remote_notif_state_allocate): Likewise. * remote.c (demand_private_info): Likewise. (remote_notif_stop_alloc_reply): Likewise. (remote_enable_btrace): Likewise. * reverse.c (save_bookmark_command): Likewise. * rl78-tdep.c (rl78_gdbarch_init): Likewise. * rx-tdep.c (rx_gdbarch_init): Likewise. * s390-linux-nat.c (s390_insert_watchpoint): Likewise. * ser-go32.c (dos_get_tty_state): Likewise. (dos_copy_tty_state): Likewise. * ser-mingw.c (ser_windows_open): Likewise. (ser_console_wait_handle): Likewise. (ser_console_get_tty_state): Likewise. (make_pipe_state): Likewise. (net_windows_open): Likewise. * ser-unix.c (hardwire_get_tty_state): Likewise. (hardwire_copy_tty_state): Likewise. * solib-aix.c (solib_aix_new_lm_info): Likewise. * solib-dsbt.c (dsbt_current_sos): Likewise. (dsbt_relocate_main_executable): Likewise. * solib-frv.c (frv_current_sos): Likewise. (frv_relocate_main_executable): Likewise. * solib-spu.c (spu_bfd_fopen): Likewise. * solib-svr4.c (lm_info_read): Likewise. (svr4_copy_library_list): Likewise. (svr4_default_sos): Likewise. * source.c (find_source_lines): Likewise. (line_info): Likewise. (add_substitute_path_rule): Likewise. * spu-linux-nat.c (spu_bfd_open): Likewise. * spu-tdep.c (info_spu_dma_cmdlist): Likewise. * stabsread.c (dbx_lookup_type): Likewise. (read_type): Likewise. (read_member_functions): Likewise. (read_struct_fields): Likewise. (read_baseclasses): Likewise. (read_args): Likewise. (_initialize_stabsread): Likewise. * stack.c (func_command): Likewise. * stap-probe.c (handle_stap_probe): Likewise. * symfile.c (addrs_section_sort): Likewise. (addr_info_make_relative): Likewise. (load_section_callback): Likewise. (add_symbol_file_command): Likewise. (init_filename_language_table): Likewise. * symtab.c (create_filename_seen_cache): Likewise. (sort_search_symbols_remove_dups): Likewise. (search_symbols): Likewise. * target.c (make_cleanup_restore_target_terminal): Likewise. * thread.c (new_thread): Likewise. (enable_thread_stack_temporaries): Likewise. (make_cleanup_restore_current_thread): Likewise. (thread_apply_all_command): Likewise. * tic6x-tdep.c (tic6x_gdbarch_init): Likewise. * top.c (gdb_readline_wrapper): Likewise. * tracefile-tfile.c (tfile_trace_file_writer_new): Likewise. * tracepoint.c (trace_find_line_command): Likewise. (all_tracepoint_actions_and_cleanup): Likewise. (make_cleanup_restore_current_traceframe): Likewise. (get_uploaded_tp): Likewise. (get_uploaded_tsv): Likewise. * tui/tui-data.c (tui_alloc_generic_win_info): Likewise. (tui_alloc_win_info): Likewise. (tui_alloc_content): Likewise. (tui_add_content_elements): Likewise. * tui/tui-disasm.c (tui_find_disassembly_address): Likewise. (tui_set_disassem_content): Likewise. * ui-file.c (ui_file_new): Likewise. (stdio_file_new): Likewise. (tee_file_new): Likewise. * utils.c (make_cleanup_restore_integer): Likewise. (add_internal_problem_command): Likewise. * v850-tdep.c (v850_gdbarch_init): Likewise. * valops.c (find_oload_champ): Likewise. * value.c (allocate_value_lazy): Likewise. (record_latest_value): Likewise. (create_internalvar): Likewise. * varobj.c (install_variable): Likewise. (new_variable): Likewise. (new_root_variable): Likewise. (cppush): Likewise. (_initialize_varobj): Likewise. * windows-nat.c (windows_make_so): Likewise. * x86-nat.c (x86_add_process): Likewise. * xcoffread.c (arrange_linetable): Likewise. (allocate_include_entry): Likewise. (process_linenos): Likewise. (SYMBOL_DUP): Likewise. (xcoff_start_psymtab): Likewise. (xcoff_end_psymtab): Likewise. * xml-support.c (gdb_xml_parse_attr_ulongest): Likewise. * xtensa-tdep.c (xtensa_register_type): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Regenerate. gdb/gdbserver/ChangeLog: * ax.c (gdb_parse_agent_expr): Likewise. (compile_bytecodes): Likewise. * dll.c (loaded_dll): Likewise. * event-loop.c (append_callback_event): Likewise. (create_file_handler): Likewise. (create_file_event): Likewise. * hostio.c (handle_open): Likewise. * inferiors.c (add_thread): Likewise. (add_process): Likewise. * linux-aarch64-low.c (aarch64_linux_new_process): Likewise. * linux-arm-low.c (arm_new_process): Likewise. (arm_new_thread): Likewise. * linux-low.c (add_to_pid_list): Likewise. (linux_add_process): Likewise. (handle_extended_wait): Likewise. (add_lwp): Likewise. (enqueue_one_deferred_signal): Likewise. (enqueue_pending_signal): Likewise. (linux_resume_one_lwp_throw): Likewise. (linux_resume_one_thread): Likewise. (linux_read_memory): Likewise. (linux_write_memory): Likewise. * linux-mips-low.c (mips_linux_new_process): Likewise. (mips_linux_new_thread): Likewise. (mips_add_watchpoint): Likewise. * linux-x86-low.c (initialize_low_arch): Likewise. * lynx-low.c (lynx_add_process): Likewise. * mem-break.c (set_raw_breakpoint_at): Likewise. (set_breakpoint): Likewise. (add_condition_to_breakpoint): Likewise. (add_commands_to_breakpoint): Likewise. (clone_agent_expr): Likewise. (clone_one_breakpoint): Likewise. * regcache.c (new_register_cache): Likewise. * remote-utils.c (look_up_one_symbol): Likewise. * server.c (queue_stop_reply): Likewise. (start_inferior): Likewise. (queue_stop_reply_callback): Likewise. (handle_target_event): Likewise. * spu-low.c (fetch_ppc_memory): Likewise. (store_ppc_memory): Likewise. * target.c (set_target_ops): Likewise. * thread-db.c (thread_db_load_search): Likewise. (try_thread_db_load_1): Likewise. * tracepoint.c (add_tracepoint): Likewise. (add_tracepoint_action): Likewise. (create_trace_state_variable): Likewise. (cmd_qtdpsrc): Likewise. (cmd_qtro): Likewise. (add_while_stepping_state): Likewise. * win32-low.c (child_add_thread): Likewise. (get_image_name): Likewise.
913 lines
24 KiB
C
913 lines
24 KiB
C
/* GNU/Linux/MIPS specific low level interface, for the remote server for GDB.
|
|
Copyright (C) 1995-2015 Free Software Foundation, Inc.
|
|
|
|
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
|
|
the Free Software Foundation; either version 3 of the License, or
|
|
(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
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
|
#include "server.h"
|
|
#include "linux-low.h"
|
|
|
|
#include "nat/gdb_ptrace.h"
|
|
#include <endian.h>
|
|
|
|
#include "nat/mips-linux-watch.h"
|
|
#include "gdb_proc_service.h"
|
|
|
|
/* Defined in auto-generated file mips-linux.c. */
|
|
void init_registers_mips_linux (void);
|
|
extern const struct target_desc *tdesc_mips_linux;
|
|
|
|
/* Defined in auto-generated file mips-dsp-linux.c. */
|
|
void init_registers_mips_dsp_linux (void);
|
|
extern const struct target_desc *tdesc_mips_dsp_linux;
|
|
|
|
/* Defined in auto-generated file mips64-linux.c. */
|
|
void init_registers_mips64_linux (void);
|
|
extern const struct target_desc *tdesc_mips64_linux;
|
|
|
|
/* Defined in auto-generated file mips64-dsp-linux.c. */
|
|
void init_registers_mips64_dsp_linux (void);
|
|
extern const struct target_desc *tdesc_mips64_dsp_linux;
|
|
|
|
#ifdef __mips64
|
|
#define tdesc_mips_linux tdesc_mips64_linux
|
|
#define tdesc_mips_dsp_linux tdesc_mips64_dsp_linux
|
|
#endif
|
|
|
|
#ifndef PTRACE_GET_THREAD_AREA
|
|
#define PTRACE_GET_THREAD_AREA 25
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_REG_H
|
|
#include <sys/reg.h>
|
|
#endif
|
|
|
|
#define mips_num_regs 73
|
|
#define mips_dsp_num_regs 80
|
|
|
|
#include <asm/ptrace.h>
|
|
|
|
#ifndef DSP_BASE
|
|
#define DSP_BASE 71
|
|
#define DSP_CONTROL 77
|
|
#endif
|
|
|
|
union mips_register
|
|
{
|
|
unsigned char buf[8];
|
|
|
|
/* Deliberately signed, for proper sign extension. */
|
|
int reg32;
|
|
long long reg64;
|
|
};
|
|
|
|
/* Return the ptrace ``address'' of register REGNO. */
|
|
|
|
#define mips_base_regs \
|
|
-1, 1, 2, 3, 4, 5, 6, 7, \
|
|
8, 9, 10, 11, 12, 13, 14, 15, \
|
|
16, 17, 18, 19, 20, 21, 22, 23, \
|
|
24, 25, 26, 27, 28, 29, 30, 31, \
|
|
\
|
|
-1, MMLO, MMHI, BADVADDR, CAUSE, PC, \
|
|
\
|
|
FPR_BASE, FPR_BASE + 1, FPR_BASE + 2, FPR_BASE + 3, \
|
|
FPR_BASE + 4, FPR_BASE + 5, FPR_BASE + 6, FPR_BASE + 7, \
|
|
FPR_BASE + 8, FPR_BASE + 9, FPR_BASE + 10, FPR_BASE + 11, \
|
|
FPR_BASE + 12, FPR_BASE + 13, FPR_BASE + 14, FPR_BASE + 15, \
|
|
FPR_BASE + 16, FPR_BASE + 17, FPR_BASE + 18, FPR_BASE + 19, \
|
|
FPR_BASE + 20, FPR_BASE + 21, FPR_BASE + 22, FPR_BASE + 23, \
|
|
FPR_BASE + 24, FPR_BASE + 25, FPR_BASE + 26, FPR_BASE + 27, \
|
|
FPR_BASE + 28, FPR_BASE + 29, FPR_BASE + 30, FPR_BASE + 31, \
|
|
FPC_CSR, FPC_EIR
|
|
|
|
#define mips_dsp_regs \
|
|
DSP_BASE, DSP_BASE + 1, DSP_BASE + 2, DSP_BASE + 3, \
|
|
DSP_BASE + 4, DSP_BASE + 5, \
|
|
DSP_CONTROL
|
|
|
|
static int mips_regmap[mips_num_regs] = {
|
|
mips_base_regs,
|
|
0
|
|
};
|
|
|
|
static int mips_dsp_regmap[mips_dsp_num_regs] = {
|
|
mips_base_regs,
|
|
mips_dsp_regs,
|
|
0
|
|
};
|
|
|
|
/* DSP registers are not in any regset and can only be accessed
|
|
individually. */
|
|
|
|
static unsigned char mips_dsp_regset_bitmap[(mips_dsp_num_regs + 7) / 8] = {
|
|
0xfe, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x80
|
|
};
|
|
|
|
static int have_dsp = -1;
|
|
|
|
/* Try peeking at an arbitrarily chosen DSP register and pick the available
|
|
user register set accordingly. */
|
|
|
|
static const struct target_desc *
|
|
mips_read_description (void)
|
|
{
|
|
if (have_dsp < 0)
|
|
{
|
|
int pid = lwpid_of (current_thread);
|
|
|
|
errno = 0;
|
|
ptrace (PTRACE_PEEKUSER, pid, DSP_CONTROL, 0);
|
|
switch (errno)
|
|
{
|
|
case 0:
|
|
have_dsp = 1;
|
|
break;
|
|
case EIO:
|
|
have_dsp = 0;
|
|
break;
|
|
default:
|
|
perror_with_name ("ptrace");
|
|
break;
|
|
}
|
|
}
|
|
|
|
return have_dsp ? tdesc_mips_dsp_linux : tdesc_mips_linux;
|
|
}
|
|
|
|
static void
|
|
mips_arch_setup (void)
|
|
{
|
|
current_process ()->tdesc = mips_read_description ();
|
|
}
|
|
|
|
static struct usrregs_info *
|
|
get_usrregs_info (void)
|
|
{
|
|
const struct regs_info *regs_info = the_low_target.regs_info ();
|
|
|
|
return regs_info->usrregs;
|
|
}
|
|
|
|
/* Per-process arch-specific data we want to keep. */
|
|
|
|
struct arch_process_info
|
|
{
|
|
/* -1 if the kernel and/or CPU do not support watch registers.
|
|
1 if watch_readback is valid and we can read style, num_valid
|
|
and the masks.
|
|
0 if we need to read the watch_readback. */
|
|
|
|
int watch_readback_valid;
|
|
|
|
/* Cached watch register read values. */
|
|
|
|
struct pt_watch_regs watch_readback;
|
|
|
|
/* Current watchpoint requests for this process. */
|
|
|
|
struct mips_watchpoint *current_watches;
|
|
|
|
/* The current set of watch register values for writing the
|
|
registers. */
|
|
|
|
struct pt_watch_regs watch_mirror;
|
|
};
|
|
|
|
/* Per-thread arch-specific data we want to keep. */
|
|
|
|
struct arch_lwp_info
|
|
{
|
|
/* Non-zero if our copy differs from what's recorded in the thread. */
|
|
int watch_registers_changed;
|
|
};
|
|
|
|
/* From mips-linux-nat.c. */
|
|
|
|
/* Pseudo registers can not be read. ptrace does not provide a way to
|
|
read (or set) PS_REGNUM, and there's no point in reading or setting
|
|
ZERO_REGNUM. We also can not set BADVADDR, CAUSE, or FCRIR via
|
|
ptrace(). */
|
|
|
|
static int
|
|
mips_cannot_fetch_register (int regno)
|
|
{
|
|
const struct target_desc *tdesc;
|
|
|
|
if (get_usrregs_info ()->regmap[regno] == -1)
|
|
return 1;
|
|
|
|
tdesc = current_process ()->tdesc;
|
|
|
|
if (find_regno (tdesc, "r0") == regno)
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int
|
|
mips_cannot_store_register (int regno)
|
|
{
|
|
const struct target_desc *tdesc;
|
|
|
|
if (get_usrregs_info ()->regmap[regno] == -1)
|
|
return 1;
|
|
|
|
tdesc = current_process ()->tdesc;
|
|
|
|
if (find_regno (tdesc, "r0") == regno)
|
|
return 1;
|
|
|
|
if (find_regno (tdesc, "cause") == regno)
|
|
return 1;
|
|
|
|
if (find_regno (tdesc, "badvaddr") == regno)
|
|
return 1;
|
|
|
|
if (find_regno (tdesc, "fir") == regno)
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static CORE_ADDR
|
|
mips_get_pc (struct regcache *regcache)
|
|
{
|
|
union mips_register pc;
|
|
collect_register_by_name (regcache, "pc", pc.buf);
|
|
return register_size (regcache->tdesc, 0) == 4 ? pc.reg32 : pc.reg64;
|
|
}
|
|
|
|
static void
|
|
mips_set_pc (struct regcache *regcache, CORE_ADDR pc)
|
|
{
|
|
union mips_register newpc;
|
|
if (register_size (regcache->tdesc, 0) == 4)
|
|
newpc.reg32 = pc;
|
|
else
|
|
newpc.reg64 = pc;
|
|
|
|
supply_register_by_name (regcache, "pc", newpc.buf);
|
|
}
|
|
|
|
/* Correct in either endianness. */
|
|
static const unsigned int mips_breakpoint = 0x0005000d;
|
|
#define mips_breakpoint_len 4
|
|
|
|
/* We only place breakpoints in empty marker functions, and thread locking
|
|
is outside of the function. So rather than importing software single-step,
|
|
we can just run until exit. */
|
|
static CORE_ADDR
|
|
mips_reinsert_addr (void)
|
|
{
|
|
struct regcache *regcache = get_thread_regcache (current_thread, 1);
|
|
union mips_register ra;
|
|
collect_register_by_name (regcache, "r31", ra.buf);
|
|
return register_size (regcache->tdesc, 0) == 4 ? ra.reg32 : ra.reg64;
|
|
}
|
|
|
|
static int
|
|
mips_breakpoint_at (CORE_ADDR where)
|
|
{
|
|
unsigned int insn;
|
|
|
|
(*the_target->read_memory) (where, (unsigned char *) &insn, 4);
|
|
if (insn == mips_breakpoint)
|
|
return 1;
|
|
|
|
/* If necessary, recognize more trap instructions here. GDB only uses the
|
|
one. */
|
|
return 0;
|
|
}
|
|
|
|
/* Mark the watch registers of lwp, represented by ENTRY, as changed,
|
|
if the lwp's process id is *PID_P. */
|
|
|
|
static int
|
|
update_watch_registers_callback (struct inferior_list_entry *entry,
|
|
void *pid_p)
|
|
{
|
|
struct thread_info *thread = (struct thread_info *) entry;
|
|
struct lwp_info *lwp = get_thread_lwp (thread);
|
|
int pid = *(int *) pid_p;
|
|
|
|
/* Only update the threads of this process. */
|
|
if (pid_of (thread) == pid)
|
|
{
|
|
/* The actual update is done later just before resuming the lwp,
|
|
we just mark that the registers need updating. */
|
|
lwp->arch_private->watch_registers_changed = 1;
|
|
|
|
/* If the lwp isn't stopped, force it to momentarily pause, so
|
|
we can update its watch registers. */
|
|
if (!lwp->stopped)
|
|
linux_stop_lwp (lwp);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method
|
|
new_process. */
|
|
|
|
static struct arch_process_info *
|
|
mips_linux_new_process (void)
|
|
{
|
|
struct arch_process_info *info = XCNEW (struct arch_process_info);
|
|
|
|
return info;
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method new_thread.
|
|
Mark the watch registers as changed, so the threads' copies will
|
|
be updated. */
|
|
|
|
static void
|
|
mips_linux_new_thread (struct lwp_info *lwp)
|
|
{
|
|
struct arch_lwp_info *info = XCNEW (struct arch_lwp_info);
|
|
|
|
info->watch_registers_changed = 1;
|
|
|
|
lwp->arch_private = info;
|
|
}
|
|
|
|
/* Create a new mips_watchpoint and add it to the list. */
|
|
|
|
static void
|
|
mips_add_watchpoint (struct arch_process_info *private, CORE_ADDR addr,
|
|
int len, int watch_type)
|
|
{
|
|
struct mips_watchpoint *new_watch;
|
|
struct mips_watchpoint **pw;
|
|
|
|
new_watch = XNEW (struct mips_watchpoint);
|
|
new_watch->addr = addr;
|
|
new_watch->len = len;
|
|
new_watch->type = watch_type;
|
|
new_watch->next = NULL;
|
|
|
|
pw = &private->current_watches;
|
|
while (*pw != NULL)
|
|
pw = &(*pw)->next;
|
|
*pw = new_watch;
|
|
}
|
|
|
|
/* Hook to call when a new fork is attached. */
|
|
|
|
static void
|
|
mips_linux_new_fork (struct process_info *parent,
|
|
struct process_info *child)
|
|
{
|
|
struct arch_process_info *parent_private;
|
|
struct arch_process_info *child_private;
|
|
struct mips_watchpoint *wp;
|
|
|
|
/* These are allocated by linux_add_process. */
|
|
gdb_assert (parent->priv != NULL
|
|
&& parent->priv->arch_private != NULL);
|
|
gdb_assert (child->priv != NULL
|
|
&& child->priv->arch_private != NULL);
|
|
|
|
/* Linux kernel before 2.6.33 commit
|
|
72f674d203cd230426437cdcf7dd6f681dad8b0d
|
|
will inherit hardware debug registers from parent
|
|
on fork/vfork/clone. Newer Linux kernels create such tasks with
|
|
zeroed debug registers.
|
|
|
|
GDB core assumes the child inherits the watchpoints/hw
|
|
breakpoints of the parent, and will remove them all from the
|
|
forked off process. Copy the debug registers mirrors into the
|
|
new process so that all breakpoints and watchpoints can be
|
|
removed together. The debug registers mirror will become zeroed
|
|
in the end before detaching the forked off process, thus making
|
|
this compatible with older Linux kernels too. */
|
|
|
|
parent_private = parent->priv->arch_private;
|
|
child_private = child->priv->arch_private;
|
|
|
|
child_private->watch_readback_valid = parent_private->watch_readback_valid;
|
|
child_private->watch_readback = parent_private->watch_readback;
|
|
|
|
for (wp = parent_private->current_watches; wp != NULL; wp = wp->next)
|
|
mips_add_watchpoint (child_private, wp->addr, wp->len, wp->type);
|
|
|
|
child_private->watch_mirror = parent_private->watch_mirror;
|
|
}
|
|
/* This is the implementation of linux_target_ops method
|
|
prepare_to_resume. If the watch regs have changed, update the
|
|
thread's copies. */
|
|
|
|
static void
|
|
mips_linux_prepare_to_resume (struct lwp_info *lwp)
|
|
{
|
|
ptid_t ptid = ptid_of (get_lwp_thread (lwp));
|
|
struct process_info *proc = find_process_pid (ptid_get_pid (ptid));
|
|
struct arch_process_info *priv = proc->priv->arch_private;
|
|
|
|
if (lwp->arch_private->watch_registers_changed)
|
|
{
|
|
/* Only update the watch registers if we have set or unset a
|
|
watchpoint already. */
|
|
if (mips_linux_watch_get_num_valid (&priv->watch_mirror) > 0)
|
|
{
|
|
/* Write the mirrored watch register values. */
|
|
int tid = ptid_get_lwp (ptid);
|
|
|
|
if (-1 == ptrace (PTRACE_SET_WATCH_REGS, tid,
|
|
&priv->watch_mirror, NULL))
|
|
perror_with_name ("Couldn't write watch register");
|
|
}
|
|
|
|
lwp->arch_private->watch_registers_changed = 0;
|
|
}
|
|
}
|
|
|
|
static int
|
|
mips_supports_z_point_type (char z_type)
|
|
{
|
|
switch (z_type)
|
|
{
|
|
case Z_PACKET_WRITE_WP:
|
|
case Z_PACKET_READ_WP:
|
|
case Z_PACKET_ACCESS_WP:
|
|
return 1;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method
|
|
insert_point. */
|
|
|
|
static int
|
|
mips_insert_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int len, struct raw_breakpoint *bp)
|
|
{
|
|
struct process_info *proc = current_process ();
|
|
struct arch_process_info *priv = proc->priv->arch_private;
|
|
struct pt_watch_regs regs;
|
|
int pid;
|
|
long lwpid;
|
|
enum target_hw_bp_type watch_type;
|
|
uint32_t irw;
|
|
|
|
lwpid = lwpid_of (current_thread);
|
|
if (!mips_linux_read_watch_registers (lwpid,
|
|
&priv->watch_readback,
|
|
&priv->watch_readback_valid,
|
|
0))
|
|
return -1;
|
|
|
|
if (len <= 0)
|
|
return -1;
|
|
|
|
regs = priv->watch_readback;
|
|
/* Add the current watches. */
|
|
mips_linux_watch_populate_regs (priv->current_watches, ®s);
|
|
|
|
/* Now try to add the new watch. */
|
|
watch_type = raw_bkpt_type_to_target_hw_bp_type (type);
|
|
irw = mips_linux_watch_type_to_irw (watch_type);
|
|
if (!mips_linux_watch_try_one_watch (®s, addr, len, irw))
|
|
return -1;
|
|
|
|
/* It fit. Stick it on the end of the list. */
|
|
mips_add_watchpoint (priv, addr, len, watch_type);
|
|
|
|
priv->watch_mirror = regs;
|
|
|
|
/* Only update the threads of this process. */
|
|
pid = pid_of (proc);
|
|
find_inferior (&all_threads, update_watch_registers_callback, &pid);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method
|
|
remove_point. */
|
|
|
|
static int
|
|
mips_remove_point (enum raw_bkpt_type type, CORE_ADDR addr,
|
|
int len, struct raw_breakpoint *bp)
|
|
{
|
|
struct process_info *proc = current_process ();
|
|
struct arch_process_info *priv = proc->priv->arch_private;
|
|
|
|
int deleted_one;
|
|
int pid;
|
|
enum target_hw_bp_type watch_type;
|
|
|
|
struct mips_watchpoint **pw;
|
|
struct mips_watchpoint *w;
|
|
|
|
/* Search for a known watch that matches. Then unlink and free it. */
|
|
watch_type = raw_bkpt_type_to_target_hw_bp_type (type);
|
|
deleted_one = 0;
|
|
pw = &priv->current_watches;
|
|
while ((w = *pw))
|
|
{
|
|
if (w->addr == addr && w->len == len && w->type == watch_type)
|
|
{
|
|
*pw = w->next;
|
|
free (w);
|
|
deleted_one = 1;
|
|
break;
|
|
}
|
|
pw = &(w->next);
|
|
}
|
|
|
|
if (!deleted_one)
|
|
return -1; /* We don't know about it, fail doing nothing. */
|
|
|
|
/* At this point watch_readback is known to be valid because we
|
|
could not have added the watch without reading it. */
|
|
gdb_assert (priv->watch_readback_valid == 1);
|
|
|
|
priv->watch_mirror = priv->watch_readback;
|
|
mips_linux_watch_populate_regs (priv->current_watches,
|
|
&priv->watch_mirror);
|
|
|
|
/* Only update the threads of this process. */
|
|
pid = pid_of (proc);
|
|
find_inferior (&all_threads, update_watch_registers_callback, &pid);
|
|
return 0;
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method
|
|
stopped_by_watchpoint. The watchhi R and W bits indicate
|
|
the watch register triggered. */
|
|
|
|
static int
|
|
mips_stopped_by_watchpoint (void)
|
|
{
|
|
struct process_info *proc = current_process ();
|
|
struct arch_process_info *priv = proc->priv->arch_private;
|
|
int n;
|
|
int num_valid;
|
|
long lwpid = lwpid_of (current_thread);
|
|
|
|
if (!mips_linux_read_watch_registers (lwpid,
|
|
&priv->watch_readback,
|
|
&priv->watch_readback_valid,
|
|
1))
|
|
return 0;
|
|
|
|
num_valid = mips_linux_watch_get_num_valid (&priv->watch_readback);
|
|
|
|
for (n = 0; n < MAX_DEBUG_REGISTER && n < num_valid; n++)
|
|
if (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
|
|
& (R_MASK | W_MASK))
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* This is the implementation of linux_target_ops method
|
|
stopped_data_address. */
|
|
|
|
static CORE_ADDR
|
|
mips_stopped_data_address (void)
|
|
{
|
|
struct process_info *proc = current_process ();
|
|
struct arch_process_info *priv = proc->priv->arch_private;
|
|
int n;
|
|
int num_valid;
|
|
long lwpid = lwpid_of (current_thread);
|
|
|
|
/* On MIPS we don't know the low order 3 bits of the data address.
|
|
GDB does not support remote targets that can't report the
|
|
watchpoint address. So, make our best guess; return the starting
|
|
address of a watchpoint request which overlaps the one that
|
|
triggered. */
|
|
|
|
if (!mips_linux_read_watch_registers (lwpid,
|
|
&priv->watch_readback,
|
|
&priv->watch_readback_valid,
|
|
0))
|
|
return 0;
|
|
|
|
num_valid = mips_linux_watch_get_num_valid (&priv->watch_readback);
|
|
|
|
for (n = 0; n < MAX_DEBUG_REGISTER && n < num_valid; n++)
|
|
if (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
|
|
& (R_MASK | W_MASK))
|
|
{
|
|
CORE_ADDR t_low, t_hi;
|
|
int t_irw;
|
|
struct mips_watchpoint *watch;
|
|
|
|
t_low = mips_linux_watch_get_watchlo (&priv->watch_readback, n);
|
|
t_irw = t_low & IRW_MASK;
|
|
t_hi = (mips_linux_watch_get_watchhi (&priv->watch_readback, n)
|
|
| IRW_MASK);
|
|
t_low &= ~(CORE_ADDR)t_hi;
|
|
|
|
for (watch = priv->current_watches;
|
|
watch != NULL;
|
|
watch = watch->next)
|
|
{
|
|
CORE_ADDR addr = watch->addr;
|
|
CORE_ADDR last_byte = addr + watch->len - 1;
|
|
|
|
if ((t_irw & mips_linux_watch_type_to_irw (watch->type)) == 0)
|
|
{
|
|
/* Different type. */
|
|
continue;
|
|
}
|
|
/* Check for overlap of even a single byte. */
|
|
if (last_byte >= t_low && addr <= t_low + t_hi)
|
|
return addr;
|
|
}
|
|
}
|
|
|
|
/* Shouldn't happen. */
|
|
return 0;
|
|
}
|
|
|
|
/* Fetch the thread-local storage pointer for libthread_db. */
|
|
|
|
ps_err_e
|
|
ps_get_thread_area (const struct ps_prochandle *ph,
|
|
lwpid_t lwpid, int idx, void **base)
|
|
{
|
|
if (ptrace (PTRACE_GET_THREAD_AREA, lwpid, NULL, base) != 0)
|
|
return PS_ERR;
|
|
|
|
/* IDX is the bias from the thread pointer to the beginning of the
|
|
thread descriptor. It has to be subtracted due to implementation
|
|
quirks in libthread_db. */
|
|
*base = (void *) ((char *)*base - idx);
|
|
|
|
return PS_OK;
|
|
}
|
|
|
|
#ifdef HAVE_PTRACE_GETREGS
|
|
|
|
static void
|
|
mips_collect_register (struct regcache *regcache,
|
|
int use_64bit, int regno, union mips_register *reg)
|
|
{
|
|
union mips_register tmp_reg;
|
|
|
|
if (use_64bit)
|
|
{
|
|
collect_register (regcache, regno, &tmp_reg.reg64);
|
|
*reg = tmp_reg;
|
|
}
|
|
else
|
|
{
|
|
collect_register (regcache, regno, &tmp_reg.reg32);
|
|
reg->reg64 = tmp_reg.reg32;
|
|
}
|
|
}
|
|
|
|
static void
|
|
mips_supply_register (struct regcache *regcache,
|
|
int use_64bit, int regno, const union mips_register *reg)
|
|
{
|
|
int offset = 0;
|
|
|
|
/* For big-endian 32-bit targets, ignore the high four bytes of each
|
|
eight-byte slot. */
|
|
if (__BYTE_ORDER == __BIG_ENDIAN && !use_64bit)
|
|
offset = 4;
|
|
|
|
supply_register (regcache, regno, reg->buf + offset);
|
|
}
|
|
|
|
static void
|
|
mips_collect_register_32bit (struct regcache *regcache,
|
|
int use_64bit, int regno, unsigned char *buf)
|
|
{
|
|
union mips_register tmp_reg;
|
|
int reg32;
|
|
|
|
mips_collect_register (regcache, use_64bit, regno, &tmp_reg);
|
|
reg32 = tmp_reg.reg64;
|
|
memcpy (buf, ®32, 4);
|
|
}
|
|
|
|
static void
|
|
mips_supply_register_32bit (struct regcache *regcache,
|
|
int use_64bit, int regno, const unsigned char *buf)
|
|
{
|
|
union mips_register tmp_reg;
|
|
int reg32;
|
|
|
|
memcpy (®32, buf, 4);
|
|
tmp_reg.reg64 = reg32;
|
|
mips_supply_register (regcache, use_64bit, regno, &tmp_reg);
|
|
}
|
|
|
|
static void
|
|
mips_fill_gregset (struct regcache *regcache, void *buf)
|
|
{
|
|
union mips_register *regset = buf;
|
|
int i, use_64bit;
|
|
const struct target_desc *tdesc = regcache->tdesc;
|
|
|
|
use_64bit = (register_size (tdesc, 0) == 8);
|
|
|
|
for (i = 1; i < 32; i++)
|
|
mips_collect_register (regcache, use_64bit, i, regset + i);
|
|
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "lo"), regset + 32);
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "hi"), regset + 33);
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "pc"), regset + 34);
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "badvaddr"), regset + 35);
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "status"), regset + 36);
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "cause"), regset + 37);
|
|
|
|
mips_collect_register (regcache, use_64bit,
|
|
find_regno (tdesc, "restart"), regset + 0);
|
|
}
|
|
|
|
static void
|
|
mips_store_gregset (struct regcache *regcache, const void *buf)
|
|
{
|
|
const union mips_register *regset = buf;
|
|
int i, use_64bit;
|
|
|
|
use_64bit = (register_size (regcache->tdesc, 0) == 8);
|
|
|
|
for (i = 0; i < 32; i++)
|
|
mips_supply_register (regcache, use_64bit, i, regset + i);
|
|
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "lo"), regset + 32);
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "hi"), regset + 33);
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "pc"), regset + 34);
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "badvaddr"), regset + 35);
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "status"), regset + 36);
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "cause"), regset + 37);
|
|
|
|
mips_supply_register (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "restart"), regset + 0);
|
|
}
|
|
|
|
static void
|
|
mips_fill_fpregset (struct regcache *regcache, void *buf)
|
|
{
|
|
union mips_register *regset = buf;
|
|
int i, use_64bit, first_fp, big_endian;
|
|
|
|
use_64bit = (register_size (regcache->tdesc, 0) == 8);
|
|
first_fp = find_regno (regcache->tdesc, "f0");
|
|
big_endian = (__BYTE_ORDER == __BIG_ENDIAN);
|
|
|
|
/* See GDB for a discussion of this peculiar layout. */
|
|
for (i = 0; i < 32; i++)
|
|
if (use_64bit)
|
|
collect_register (regcache, first_fp + i, regset[i].buf);
|
|
else
|
|
collect_register (regcache, first_fp + i,
|
|
regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
|
|
|
|
mips_collect_register_32bit (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "fcsr"), regset[32].buf);
|
|
mips_collect_register_32bit (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "fir"),
|
|
regset[32].buf + 4);
|
|
}
|
|
|
|
static void
|
|
mips_store_fpregset (struct regcache *regcache, const void *buf)
|
|
{
|
|
const union mips_register *regset = buf;
|
|
int i, use_64bit, first_fp, big_endian;
|
|
|
|
use_64bit = (register_size (regcache->tdesc, 0) == 8);
|
|
first_fp = find_regno (regcache->tdesc, "f0");
|
|
big_endian = (__BYTE_ORDER == __BIG_ENDIAN);
|
|
|
|
/* See GDB for a discussion of this peculiar layout. */
|
|
for (i = 0; i < 32; i++)
|
|
if (use_64bit)
|
|
supply_register (regcache, first_fp + i, regset[i].buf);
|
|
else
|
|
supply_register (regcache, first_fp + i,
|
|
regset[i & ~1].buf + 4 * (big_endian != (i & 1)));
|
|
|
|
mips_supply_register_32bit (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "fcsr"),
|
|
regset[32].buf);
|
|
mips_supply_register_32bit (regcache, use_64bit,
|
|
find_regno (regcache->tdesc, "fir"),
|
|
regset[32].buf + 4);
|
|
}
|
|
#endif /* HAVE_PTRACE_GETREGS */
|
|
|
|
static struct regset_info mips_regsets[] = {
|
|
#ifdef HAVE_PTRACE_GETREGS
|
|
{ PTRACE_GETREGS, PTRACE_SETREGS, 0, 38 * 8, GENERAL_REGS,
|
|
mips_fill_gregset, mips_store_gregset },
|
|
{ PTRACE_GETFPREGS, PTRACE_SETFPREGS, 0, 33 * 8, FP_REGS,
|
|
mips_fill_fpregset, mips_store_fpregset },
|
|
#endif /* HAVE_PTRACE_GETREGS */
|
|
{ 0, 0, 0, -1, -1, NULL, NULL }
|
|
};
|
|
|
|
static struct regsets_info mips_regsets_info =
|
|
{
|
|
mips_regsets, /* regsets */
|
|
0, /* num_regsets */
|
|
NULL, /* disabled_regsets */
|
|
};
|
|
|
|
static struct usrregs_info mips_dsp_usrregs_info =
|
|
{
|
|
mips_dsp_num_regs,
|
|
mips_dsp_regmap,
|
|
};
|
|
|
|
static struct usrregs_info mips_usrregs_info =
|
|
{
|
|
mips_num_regs,
|
|
mips_regmap,
|
|
};
|
|
|
|
static struct regs_info dsp_regs_info =
|
|
{
|
|
mips_dsp_regset_bitmap,
|
|
&mips_dsp_usrregs_info,
|
|
&mips_regsets_info
|
|
};
|
|
|
|
static struct regs_info regs_info =
|
|
{
|
|
NULL, /* regset_bitmap */
|
|
&mips_usrregs_info,
|
|
&mips_regsets_info
|
|
};
|
|
|
|
static const struct regs_info *
|
|
mips_regs_info (void)
|
|
{
|
|
if (have_dsp)
|
|
return &dsp_regs_info;
|
|
else
|
|
return ®s_info;
|
|
}
|
|
|
|
struct linux_target_ops the_low_target = {
|
|
mips_arch_setup,
|
|
mips_regs_info,
|
|
mips_cannot_fetch_register,
|
|
mips_cannot_store_register,
|
|
NULL, /* fetch_register */
|
|
mips_get_pc,
|
|
mips_set_pc,
|
|
(const unsigned char *) &mips_breakpoint,
|
|
mips_breakpoint_len,
|
|
mips_reinsert_addr,
|
|
0,
|
|
mips_breakpoint_at,
|
|
mips_supports_z_point_type,
|
|
mips_insert_point,
|
|
mips_remove_point,
|
|
mips_stopped_by_watchpoint,
|
|
mips_stopped_data_address,
|
|
NULL,
|
|
NULL,
|
|
NULL, /* siginfo_fixup */
|
|
mips_linux_new_process,
|
|
mips_linux_new_thread,
|
|
mips_linux_new_fork,
|
|
mips_linux_prepare_to_resume
|
|
};
|
|
|
|
void
|
|
initialize_low_arch (void)
|
|
{
|
|
/* Initialize the Linux target descriptions. */
|
|
init_registers_mips_linux ();
|
|
init_registers_mips_dsp_linux ();
|
|
init_registers_mips64_linux ();
|
|
init_registers_mips64_dsp_linux ();
|
|
|
|
initialize_regsets_info (&mips_regsets_info);
|
|
}
|