+2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * defs.h (extract_signed_integer, extract_unsigned_integer,
+ extract_long_unsigned_integer, store_signed_integer,
+ store_unsigned_integer): Add BYTE_ORDER parameter.
+ * findvar.c (extract_signed_integer, extract_unsigned_integer,
+ extract_long_unsigned_integer, store_signed_integer,
+ store_unsigned_integer): Add BYTE_ORDER parameter. Use it
+ instead of current_gdbarch.
+
+ * gdbcore.h (read_memory_integer, safe_read_memory_integer,
+ read_memory_unsigned_integer, write_memory_signed_integer,
+ write_memory_unsigned_integer): Add BYTE_ORDER parameter.
+ * corefile.c (struct captured_read_memory_integer_arguments): Add
+ BYTE_ORDER member.
+ (safe_read_memory_integer): Add BYTE_ORDER parameter. Store it into
+ struct captured_read_memory_integer_arguments.
+ (do_captured_read_memory_integer): Pass it to read_memory_integer.
+ (read_memory_integer): Add BYTE_ORDER parameter. Pass it to
+ extract_signed_integer.
+ (read_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it to
+ extract_unsigned_integer.
+ (write_memory_signed_integer): Add BYTE_ORDER parameter. Pass it
+ to store_signed_integer.
+ (write_memory_unsigned_integer): Add BYTE_ORDER parameter. Pass it
+ to store_unsigned_integer.
+
+ * target.h (get_target_memory_unsigned): Add BYTE_ORDER parameter.
+ * target.c (get_target_memory_unsigned): Add BYTE_ORDER parameter.
+ Pass it to extract_unsigned_integer.
+
+
+ Update calls to extract_signed_integer, extract_unsigned_integer,
+ extract_long_unsigned_integer, store_signed_integer,
+ store_unsigned_integer, read_memory_integer,
+ read_memory_unsigned_integer, safe_read_memory_integer,
+ write_memory_signed_integer, write_memory_unsigned_integer, and
+ get_target_memory_unsigned to pass byte order:
+ * ada-lang.c (ada_value_binop): Update.
+ * ada-valprint.c (char_at): Update.
+ * alpha-osf1-tdep.c (alpha_osf1_sigcontext_addr): Update.
+ * alpha-tdep.c (alpha_lds, alpha_sts, alpha_push_dummy_call,
+ alpha_extract_return_value, alpha_read_insn,
+ alpha_get_longjmp_target): Update.
+ * amd64-linux-tdep.c (amd64_linux_sigcontext_addr): Update.
+ * amd64obsd-tdep.c (amd64obsd_supply_uthread,
+ amd64obsd_collect_uthread, amd64obsd_trapframe_cache): Update.
+ * amd64-tdep.c (amd64_push_dummy_call, amd64_analyze_prologue,
+ amd64_frame_cache, amd64_sigtramp_frame_cache, fixup_riprel,
+ amd64_displaced_step_fixup): Update.
+ * arm-linux-tdep.c (arm_linux_sigreturn_init,
+ arm_linux_rt_sigreturn_init, arm_linux_supply_gregset): Update.
+ * arm-tdep.c (thumb_analyze_prologue, arm_skip_prologue,
+ arm_scan_prologue, arm_push_dummy_call, thumb_get_next_pc,
+ arm_get_next_pc, arm_extract_return_value, arm_store_return_value,
+ arm_return_value): Update.
+ * arm-wince-tdep.c (arm_pe_skip_trampoline_code): Update.
+ * auxv.c (default_auxv_parse): Update.
+ * avr-tdep.c (avr_address_to_pointer, avr_pointer_to_address,
+ avr_scan_prologue, avr_extract_return_value,
+ avr_frame_prev_register, avr_push_dummy_call): Update.
+ * bsd-uthread.c (bsd_uthread_check_magic, bsd_uthread_lookup_offset,
+ bsd_uthread_wait, bsd_uthread_thread_alive,
+ bsd_uthread_extra_thread_info): Update.
+ * c-lang.c (c_printstr, print_wchar): Update.
+ * cp-valprint.c (cp_print_class_member): Update.
+ * cris-tdep.c (cris_sigcontext_addr, cris_sigtramp_frame_unwind_cache,
+ cris_push_dummy_call, cris_scan_prologue, cris_store_return_value,
+ cris_extract_return_value, find_step_target, dip_prefix,
+ sixteen_bit_offset_branch_op, none_reg_mode_jump_op,
+ move_mem_to_reg_movem_op, get_data_from_address): Update.
+ * dwarf2expr.c (dwarf2_read_address, execute_stack_op): Update.
+ * dwarf2-frame.c (execute_cfa_program): Update.
+ * dwarf2loc.c (find_location_expression): Update.
+ * dwarf2read.c (dwarf2_const_value): Update.
+ * expprint.c (print_subexp_standard): Update.
+ * findvar.c (unsigned_pointer_to_address, signed_pointer_to_address,
+ unsigned_address_to_pointer, address_to_signed_pointer,
+ read_var_value): Update.
+ * frame.c (frame_unwind_register_signed,
+ frame_unwind_register_unsigned, get_frame_memory_signed,
+ get_frame_memory_unsigned): Update.
+ * frame-unwind.c (frame_unwind_got_constant): Update.
+ * frv-linux-tdep.c (frv_linux_pc_in_sigtramp,
+ frv_linux_sigcontext_reg_addr, frv_linux_sigtramp_frame_cache):
+ Update.
+ * frv-tdep.c (frv_analyze_prologue, frv_skip_main_prologue,
+ frv_extract_return_value, find_func_descr,
+ frv_convert_from_func_ptr_addr, frv_push_dummy_call): Update.
+ * f-valprint.c (f_val_print): Update.
+ * gnu-v3-abi.c (gnuv3_decode_method_ptr, gnuv3_make_method_ptr):
+ Update.
+ * h8300-tdep.c (h8300_is_argument_spill, h8300_analyze_prologue,
+ h8300_push_dummy_call, h8300_extract_return_value,
+ h8300h_extract_return_value, h8300_store_return_value,
+ h8300h_store_return_value): Update.
+ * hppabsd-tdep.c (hppabsd_find_global_pointer): Update.
+ * hppa-hpux-nat.c (hppa_hpux_fetch_register, hppa_hpux_store_register):
+ Update.
+ * hppa-hpux-tdep.c (hppa32_hpux_in_solib_call_trampoline,
+ hppa64_hpux_in_solib_call_trampoline,
+ hppa_hpux_in_solib_return_trampoline, hppa_hpux_skip_trampoline_code,
+ hppa_hpux_sigtramp_frame_unwind_cache,
+ hppa_hpux_sigtramp_unwind_sniffer, hppa32_hpux_find_global_pointer,
+ hppa64_hpux_find_global_pointer, hppa_hpux_search_pattern,
+ hppa32_hpux_search_dummy_call_sequence,
+ hppa64_hpux_search_dummy_call_sequence, hppa_hpux_supply_save_state,
+ hppa_hpux_unwind_adjust_stub): Update.
+ * hppa-linux-tdep.c (insns_match_pattern,
+ hppa_linux_find_global_pointer): Update.
+ * hppa-tdep.c (hppa_in_function_epilogue_p, hppa32_push_dummy_call,
+ hppa64_convert_code_addr_to_fptr, hppa64_push_dummy_call,
+ skip_prologue_hard_way, hppa_frame_cache, hppa_fallback_frame_cache,
+ hppa_pseudo_register_read, hppa_frame_prev_register_helper,
+ hppa_match_insns): Update.
+ * hpux-thread.c (hpux_thread_fetch_registers): Update.
+ * i386-tdep.c (i386bsd_sigcontext_addr): Update.
+ * i386-cygwin-tdep.c (core_process_module_section): Update.
+ * i386-darwin-nat.c (i386_darwin_sstep_at_sigreturn,
+ amd64_darwin_sstep_at_sigreturn): Update.
+ * i386-darwin-tdep.c (i386_darwin_sigcontext_addr,
+ amd64_darwin_sigcontext_addr): Likewise.
+ * i386-linux-nat.c (i386_linux_sigcontext_addr): Update.
+ * i386nbsd-tdep.c (i386nbsd_sigtramp_cache_init): Update.
+ * i386-nto-tdep.c (i386nto_sigcontext_addr): Update.
+ * i386obsd-nat.c (i386obsd_supply_pcb): Update.
+ * i386obsd-tdep.c (i386obsd_supply_uthread, i386obsd_collect_uthread,
+ i386obsd_trapframe_cache): Update.
+ * i386-tdep.c (i386_displaced_step_fixup, i386_follow_jump,
+ i386_analyze_frame_setup, i386_analyze_prologue,
+ i386_skip_main_prologue, i386_frame_cache, i386_sigtramp_frame_cache,
+ i386_get_longjmp_target, i386_push_dummy_call,
+ i386_pe_skip_trampoline_code, i386_svr4_sigcontext_addr,
+ i386_fetch_pointer_argument): Update.
+ * i387-tdep.c (i387_supply_fsave): Update.
+ * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Update.
+ * ia64-tdep.c (ia64_pseudo_register_read, ia64_pseudo_register_write,
+ examine_prologue, ia64_frame_cache, ia64_frame_prev_register,
+ ia64_sigtramp_frame_cache, ia64_sigtramp_frame_prev_register,
+ ia64_access_reg, ia64_access_rse_reg, ia64_libunwind_frame_this_id,
+ ia64_libunwind_frame_prev_register,
+ ia64_libunwind_sigtramp_frame_this_id,
+ ia64_libunwind_sigtramp_frame_prev_register, ia64_find_global_pointer,
+ find_extant_func_descr, find_func_descr,
+ ia64_convert_from_func_ptr_addr, ia64_push_dummy_call, ia64_dummy_id,
+ ia64_unwind_pc): Update.
+ * iq2000-tdep.c (iq2000_pointer_to_address, iq2000_address_to_pointer,
+ iq2000_scan_prologue, iq2000_extract_return_value,
+ iq2000_push_dummy_call): Update.
+ * irix5nat.c (fill_gregset): Update.
+ * jv-lang.c (evaluate_subexp_java): Update.
+ * jv-valprint.c (java_value_print): Update.
+ * lm32-tdep.c (lm32_analyze_prologue, lm32_push_dummy_call,
+ lm32_extract_return_value, lm32_store_return_value): Update.
+ * m32c-tdep.c (m32c_push_dummy_call, m32c_return_value,
+ m32c_skip_trampoline_code, m32c_m16c_address_to_pointer,
+ m32c_m16c_pointer_to_address): Update.
+ * m32r-tdep.c (m32r_store_return_value, decode_prologue,
+ m32r_skip_prologue, m32r_push_dummy_call, m32r_extract_return_value):
+ Update.
+ * m68hc11-tdep.c (m68hc11_pseudo_register_read,
+ m68hc11_pseudo_register_write, m68hc11_analyze_instruction,
+ m68hc11_push_dummy_call): Update.
+ * m68linux-tdep.c (m68k_linux_pc_in_sigtramp,
+ m68k_linux_get_sigtramp_info, m68k_linux_sigtramp_frame_cache):
+ Update.
+ * m68k-tdep.c (m68k_push_dummy_call, m68k_analyze_frame_setup,
+ m68k_analyze_register_saves, m68k_analyze_prologue, m68k_frame_cache,
+ m68k_get_longjmp_target): Update.
+ * m88k-tdep.c (m88k_fetch_instruction): Update.
+ * mep-tdep.c (mep_pseudo_cr32_read, mep_pseudo_csr_write,
+ mep_pseudo_cr32_write, mep_get_insn, mep_push_dummy_call): Update.
+ * mi/mi-main.c (mi_cmd_data_write_memory): Update.
+ * mips-linux-tdep.c (mips_linux_get_longjmp_target, supply_32bit_reg,
+ mips64_linux_get_longjmp_target, mips64_fill_gregset,
+ mips64_fill_fpregset, mips_linux_in_dynsym_stub): Update.
+ * mipsnbdsd-tdep.c (mipsnbsd_get_longjmp_target): Update.
+ * mips-tdep.c (mips_fetch_instruction, fetch_mips_16,
+ mips_eabi_push_dummy_call, mips_n32n64_push_dummy_call,
+ mips_o32_push_dummy_call, mips_o64_push_dummy_call,
+ mips_single_step_through_delay, mips_skip_pic_trampoline_code,
+ mips_integer_to_address): Update.
+ * mn10300-tdep.c (mn10300_analyze_prologue, mn10300_push_dummy_call):
+ Update.
+ * monitor.c (monitor_supply_register, monitor_write_memory,
+ monitor_read_memory_single): Update.
+ * moxie-tdep.c (moxie_store_return_value, moxie_extract_return_value,
+ moxie_analyze_prologue): Update.
+ * mt-tdep.c (mt_return_value, mt_skip_prologue, mt_select_coprocessor,
+ mt_pseudo_register_read, mt_pseudo_register_write, mt_registers_info,
+ mt_push_dummy_call): Update.
+ * objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
+ read_objc_methlist_method, read_objc_object, read_objc_super,
+ read_objc_class, find_implementation_from_class): Update.
+ * ppc64-linux-tdep.c (ppc64_desc_entry_point,
+ ppc64_linux_convert_from_func_ptr_addr, ppc_linux_sigtramp_cache):
+ Update.
+ * ppcobsd-tdep.c (ppcobsd_sigtramp_frame_sniffer,
+ ppcobsd_sigtramp_frame_cache): Update.
+ * ppc-sysv-tdep.c (ppc_sysv_abi_push_dummy_call,
+ do_ppc_sysv_return_value, ppc64_sysv_abi_push_dummy_call,
+ ppc64_sysv_abi_return_value): Update.
+ * ppc-linux-nat.c (ppc_linux_auxv_parse): Update.
+ * procfs.c (procfs_auxv_parse): Update.
+ * p-valprint.c (pascal_val_print): Update.
+ * regcache.c (regcache_raw_read_signed, regcache_raw_read_unsigned,
+ regcache_raw_write_signed, regcache_raw_write_unsigned,
+ regcache_cooked_read_signed, regcache_cooked_read_unsigned,
+ regcache_cooked_write_signed, regcache_cooked_write_unsigned): Update.
+ * remote-m32r-sdi.c (m32r_fetch_register): Update.
+ * remote-mips.c (mips_wait, mips_fetch_registers, mips_xfer_memory):
+ Update.
+ * rs6000-aix-tdep.c (rs6000_push_dummy_call, rs6000_return_value,
+ rs6000_convert_from_func_ptr_addr, branch_dest,
+ rs6000_software_single_step): Update.
+ * rs6000-tdep.c (rs6000_in_function_epilogue_p,
+ ppc_displaced_step_fixup, ppc_deal_with_atomic_sequence,
+ bl_to_blrl_insn_p, rs6000_fetch_instruction, skip_prologue,
+ rs6000_skip_main_prologue, rs6000_skip_trampoline_code,
+ rs6000_frame_cache): Update.
+ * s390-tdep.c (s390_pseudo_register_read, s390_pseudo_register_write,
+ s390x_pseudo_register_read, s390x_pseudo_register_write, s390_load,
+ s390_backchain_frame_unwind_cache, s390_sigtramp_frame_unwind_cache,
+ extend_simple_arg, s390_push_dummy_call, s390_return_value): Update.
+ * scm-exp.c (scm_lreadr): Update.
+ * scm-lang.c (scm_get_field, scm_unpack): Update.
+ * scm-valprint.c (scm_val_print): Update.
+ * score-tdep.c (score_breakpoint_from_pc, score_push_dummy_call,
+ score_fetch_inst): Update.
+ * sh64-tdep.c (look_for_args_moves, sh64_skip_prologue_hard_way,
+ sh64_analyze_prologue, sh64_push_dummy_call, sh64_extract_return_value,
+ sh64_pseudo_register_read, sh64_pseudo_register_write,
+ sh64_frame_prev_register): Update:
+ * sh-tdep.c (sh_analyze_prologue, sh_push_dummy_call_fpu,
+ sh_push_dummy_call_nofpu, sh_extract_return_value_nofpu,
+ sh_store_return_value_nofpu, sh_in_function_epilogue_p): Update.
+ * solib-darwin.c (darwin_load_image_infos): Update.
+ * solib-frv.c (fetch_loadmap, lm_base, frv_current_sos, enable_break2,
+ find_canonical_descriptor_in_load_object): Update.
+ * solib-irix.c (extract_mips_address, fetch_lm_info, irix_current_sos,
+ irix_open_symbol_file_object): Update.
+ * solib-som.c (som_solib_create_inferior_hook, link_map_start,
+ som_current_sos, som_open_symbol_file_object): Update.
+ * solib-sunos.c (SOLIB_EXTRACT_ADDRESS, LM_ADDR, LM_NEXT, LM_NAME):
+ Update.
+ * solib-svr4.c (read_program_header, scan_dyntag_auxv,
+ solib_svr4_r_ldsomap): Update.
+ * sparc64-linux-tdep.c (sparc64_linux_step_trap): Update.
+ * sparc64obsd-tdep.c (sparc64obsd_supply_uthread,
+ sparc64obsd_collect_uthread): Update.
+ * sparc64-tdep.c (sparc64_pseudo_register_read,
+ sparc64_pseudo_register_write, sparc64_supply_gregset,
+ sparc64_collect_gregset): Update.
+ * sparc-linux-tdep.c (sparc32_linux_step_trap): Update.
+ * sparcobsd-tdep.c (sparc32obsd_supply_uthread,
+ sparc32obsd_collect_uthread): Update.
+ * sparc-tdep.c (sparc_fetch_wcookie, sparc32_push_dummy_code,
+ sparc32_store_arguments, sparc32_return_value, sparc_supply_rwindow,
+ sparc_collect_rwindow): Update.
+ * spu-linux-nat.c (parse_spufs_run): Update.
+ * spu-tdep.c (spu_pseudo_register_read_spu,
+ spu_pseudo_register_write_spu, spu_pointer_to_address,
+ spu_analyze_prologue, spu_in_function_epilogue_p,
+ spu_frame_unwind_cache, spu_push_dummy_call, spu_software_single_step,
+ spu_get_longjmp_target, spu_get_overlay_table, spu_overlay_update_osect,
+ info_spu_signal_command, info_spu_mailbox_list, info_spu_dma_cmdlist,
+ info_spu_dma_command, info_spu_proxydma_command): Update.
+ * stack.c (print_frame_nameless_args, frame_info): Update.
+ * symfile.c (read_target_long_array, simple_read_overlay_table,
+ simple_read_overlay_region_table): Update.
+ * target.c (debug_print_register): Update.
+ * tramp-frame.c (tramp_frame_start): Update.
+ * v850-tdep.c (v850_analyze_prologue, v850_push_dummy_call,
+ v850_extract_return_value, v850_store_return_value,
+ * valarith.c (value_binop, value_bit_index): Update.
+ * valops.c (value_cast): Update.
+ * valprint.c (val_print_type_code_int, val_print_string,
+ read_string): Update.
+ * value.c (unpack_long, unpack_double, unpack_field_as_long,
+ modify_field, pack_long): Update.
+ * vax-tdep.c (vax_store_arguments, vax_push_dummy_call,
+ vax_skip_prologue): Update.
+ * xstormy16-tdep.c (xstormy16_push_dummy_call,
+ xstormy16_analyze_prologue, xstormy16_in_function_epilogue_p,
+ xstormy16_resolve_jmp_table_entry, xstormy16_find_jmp_table_entry,
+ xstormy16_pointer_to_address, xstormy16_address_to_pointer): Update.
+ * xtensa-tdep.c (extract_call_winsize, xtensa_pseudo_register_read,
+ xtensa_pseudo_register_write, xtensa_frame_cache,
+ xtensa_push_dummy_call, call0_track_op, call0_frame_cache): Update.
+
+
+ * dfp.h (decimal_to_string, decimal_from_string, decimal_from_integral,
+ decimal_from_floating, decimal_to_doublest, decimal_is_zero): Add
+ BYTE_ORDER parameter.
+ (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
+ parameters.
+ (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
+ (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
+ * dfp.c (match_endianness): Add BYTE_ORDER parameter. Use it
+ instead of current_gdbarch.
+ (decimal_to_string, decimal_from_integral, decimal_from_floating,
+ decimal_to_doublest, decimal_is_zero): Add BYTE_ORDER parameter.
+ Pass it to match_endianness.
+ (decimal_binop): Add BYTE_ORDER_X, BYTE_ORDER_Y, and BYTE_ORDER_RESULT
+ parameters. Pass them to match_endianness.
+ (decimal_compare): Add BYTE_ORDER_X and BYTE_ORDER_Y parameters.
+ Pass them to match_endianness.
+ (decimal_convert): Add BYTE_ORDER_FROM and BYTE_ORDER_TO parameters.
+ Pass them to match_endianness.
+ * valarith.c (value_args_as_decimal): Add BYTE_ORDER_X and
+ BYTE_ORDER_Y output parameters.
+ (value_binop): Update call to value_args_as_decimal.
+
+ Update calls to decimal_to_string, decimal_from_string,
+ decimal_from_integral, decimal_from_floating, decimal_to_doublest,
+ decimal_is_zero, decimal_binop, decimal_compare and decimal_convert
+ to pass/receive byte order:
+ * c-exp.y (parse_number): Update.
+ * printcmd.c (printf_command): Update.
+ * valarith.c (value_args_as_decimal, value_binop, value_logical_not,
+ value_equal, value_less): Update.
+ * valops.c (value_cast, value_one): Update.
+ * valprint.c (print_decimal_floating): Update.
+ * value.c (unpack_long, unpack_double): Update.
+ * python/python-value.c (valpy_nonzero): Update.
+
+
+ * ada-valprint.c (char_at): Add BYTE_ORDER parameter.
+ (printstr): Update calls to char_at.
+ (ada_val_print_array): Likewise.
+ * valprint.c (read_string): Add BYTE_ORDER parameter.
+ (val_print_string): Update call to read_string.
+ * c-lang.c (c_get_string): Likewise.
+ * charset.h (target_wide_charset): Add BYTE_ORDER parameter.
+ * charset.c (target_wide_charset): Add BYTE_ORDER parameter.
+ Use it instead of current_gdbarch.
+ * printcmd.c (printf_command): Update calls to target_wide_charset.
+ * c-lang.c (charset_for_string_type): Add BYTE_ORDER parameter.
+ Pass to target_wide_charset. Use it instead of current_gdbarch.
+ (classify_type): Add BYTE_ORDER parameter. Pass to
+ charset_for_string_type. Allow NULL encoding pointer.
+ (print_wchar): Add BYTE_ORDER parameter.
+ (c_emit_char): Update calls to classify_type and print_wchar.
+ (c_printchar, c_printstr): Likewise.
+
+
+ * gdbarch.sh (in_solib_return_trampoline): Convert to type "m".
+ * gdbarch.c, gdbarch.h: Regenerate.
+ * arch-utils.h (generic_in_solib_return_trampoline): Add GDBARCH
+ parameter.
+ * arch-utils.c (generic_in_solib_return_trampoline): Likewise.
+ * hppa-hpux-tdep.c (hppa_hpux_in_solib_return_trampoline): Likewise.
+ * rs6000-tdep.c (rs6000_in_solib_return_trampoline): Likewise.
+ (rs6000_skip_trampoline_code): Update call.
+
+ * alpha-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
+ dynamic_sigtramp_offset and pc_in_sigtramp callbacks.
+ (alpha_read_insn): Add GDBARCH parameter.
+ * alpha-tdep.c (alpha_lds, alpha_sts): Add GDBARCH parameter.
+ (alpha_register_to_value): Pass architecture to alpha_sts.
+ (alpha_extract_return_value): Likewise.
+ (alpha_value_to_register): Pass architecture to alpha_lds.
+ (alpha_store_return_value): Likewise.
+ (alpha_read_insn): Add GDBARCH parameter.
+ (alpha_skip_prologue): Pass architecture to alpha_read_insn.
+ (alpha_heuristic_proc_start): Likewise.
+ (alpha_heuristic_frame_unwind_cache): Likewise.
+ (alpha_next_pc): Likewise.
+ (alpha_sigtramp_frame_this_id): Pass architecture to
+ tdep->dynamic_sigtramp_offset callback.
+ (alpha_sigtramp_frame_sniffer): Pass architecture to
+ tdep->pc_in_sigtramp callback.
+ * alphafbsd-tdep.c (alphafbsd_pc_in_sigtramp): Add GDBARCH parameter.
+ (alphafbsd_sigtramp_offset): Likewise.
+ * alpha-linux-tdep.c (alpha_linux_sigtramp_offset_1): Add GDBARCH
+ parameter. Pass to alpha_read_insn.
+ (alpha_linux_sigtramp_offset): Add GDBARCH parameter. Pass to
+ alpha_linux_sigtramp_offset_1.
+ (alpha_linux_pc_in_sigtramp): Add GDBARCH parameter. Pass to
+ alpha_linux_sigtramp_offset.
+ (alpha_linux_sigcontext_addr): Pass architecture to alpha_read_insn
+ and alpha_linux_sigtramp_offset.
+ * alphanbsd-tdep.c (alphanbsd_sigtramp_offset): Add GDBARCH parameter.
+ (alphanbsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to
+ alphanbsd_sigtramp_offset.
+ * alphaobsd-tdep.c (alphaobsd_sigtramp_offset): Add GDBARCH parameter.
+ (alphaobsd_pc_in_sigtramp): Add GDBARCH parameter. Pass to
+ alpha_read_insn.
+ (alphaobsd_sigcontext_addr): Pass architecture to
+ alphaobsd_sigtramp_offset.
+ * alpha-osf1-tdep.c (alpha_osf1_pc_in_sigtramp): Add GDBARCH
+ parameter.
+
+ * amd64-tdep.c (amd64_analyze_prologue): Add GDBARCH parameter.
+ (amd64_skip_prologue): Pass architecture to amd64_analyze_prologue.
+ (amd64_frame_cache): Likewise.
+
+ * arm-tdep.c (SWAP_SHORT, SWAP_INT): Remove.
+ (thumb_analyze_prologue, arm_skip_prologue, arm_scan_prologue,
+ thumb_get_next_pc, arm_get_next_pc): Do not use SWAP_ macros.
+ * arm-wince-tdep.c: Include "frame.h".
+
+ * avr-tdep.c (EXTRACT_INSN): Remove.
+ (avr_scan_prologue): Add GDBARCH argument, inline EXTRACT_INSN.
+ (avr_skip_prologue): Pass architecture to avr_scan_prologue.
+ (avr_frame_unwind_cache): Likewise.
+
+ * cris-tdep.c (struct instruction_environment): Add BYTE_ORDER member.
+ (find_step_target): Initialize it.
+ (get_data_from_address): Add BYTE_ORDER parameter.
+ (bdap_prefix): Pass byte order to get_data_from_address.
+ (handle_prefix_assign_mode_for_aritm_op): Likewise.
+ (three_operand_add_sub_cmp_and_or_op): Likewise.
+ (handle_inc_and_index_mode_for_aritm_op): Likewise.
+
+ * frv-linux-tdep.c (frv_linux_pc_in_sigtramp): Add GDBARCH parameter.
+ (frv_linux_sigcontext_reg_addr): Pass architecture to
+ frv_linux_pc_in_sigtramp.
+ (frv_linux_sigtramp_frame_sniffer): Likewise.
+
+ * h8300-tdep.c (h8300_is_argument_spill): Add GDBARCH parameter.
+ (h8300_analyze_prologue): Add GDBARCH parameter. Pass to
+ h8300_is_argument_spill.
+ (h8300_frame_cache, h8300_skip_prologue): Pass architecture
+ to h8300_analyze_prologue.
+
+ * hppa-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter to
+ in_solib_call_trampoline callback.
+ (hppa_in_solib_call_trampoline): Add GDBARCH parameter.
+ * hppa-tdep.c (hppa64_convert_code_addr_to_fptr): Add GDBARCH
+ parameter.
+ (hppa64_push_dummy_call): Pass architecture to
+ hppa64_convert_code_addr_to_fptr.
+ (hppa_match_insns): Add GDBARCH parameter.
+ (hppa_match_insns_relaxed): Add GDBARCH parameter. Pass to
+ hppa_match_insns.
+ (hppa_skip_trampoline_code): Pass architecture to hppa_match_insns.
+ (hppa_in_solib_call_trampoline): Add GDBARCH parameter. Pass to
+ hppa_match_insns_relaxed.
+ (hppa_stub_unwind_sniffer): Pass architecture to
+ tdep->in_solib_call_trampoline callback.
+ * hppa-hpux-tdep.c (hppa_hpux_search_pattern): Add GDBARCH parameter.
+ (hppa32_hpux_search_dummy_call_sequence): Pass architecture to
+ hppa_hpux_search_pattern.
+ * hppa-linux-tdep.c (insns_match_pattern): Add GDBARCH parameter.
+ (hppa_linux_sigtramp_find_sigcontext): Add GDBARCH parameter.
+ Pass to insns_match_pattern.
+ (hppa_linux_sigtramp_frame_unwind_cache): Pass architecture to
+ hppa_linux_sigtramp_find_sigcontext.
+ (hppa_linux_sigtramp_frame_sniffer): Likewise.
+ (hppa32_hpux_in_solib_call_trampoline): Add GDBARCH parameter.
+ (hppa64_hpux_in_solib_call_trampoline): Likewise.
+
+ * i386-tdep.c (i386_follow_jump): Add GDBARCH parameter.
+ (i386_analyze_frame_setup): Add GDBARCH parameter.
+ (i386_analyze_prologue): Add GDBARCH parameter. Pass to
+ i386_follow_jump and i386_analyze_frame_setup.
+ (i386_skip_prologue): Pass architecture to i386_analyze_prologue
+ and i386_follow_jump.
+ (i386_frame_cache): Pass architecture to i386_analyze_prologue.
+ (i386_pe_skip_trampoline_code): Add FRAME parameter.
+ * i386-tdep.h (i386_pe_skip_trampoline_code): Add FRAME parameter.
+ * i386-cygwin-tdep.c (i386_cygwin_skip_trampoline_code): Pass
+ frame to i386_pe_skip_trampoline_code.
+
+ * ia64-tdep.h (struct gdbarch_tdep): Add GDBARCH parameter
+ to sigcontext_register_address callback.
+ * ia64-tdep.c (ia64_find_global_pointer): Add GDBARCH parameter.
+ (ia64_find_unwind_table): Pass architecture to
+ ia64_find_global_pointer.
+ (find_extant_func_descr): Add GDBARCH parameter.
+ (find_func_descr): Pass architecture to find_extant_func_descr
+ and ia64_find_global_pointer.
+ (ia64_sigtramp_frame_init_saved_regs): Pass architecture to
+ tdep->sigcontext_register_address callback.
+ * ia64-linux-tdep.c (ia64_linux_sigcontext_register_address): Add
+ GDBARCH parameter.
+
+ * iq2000-tdep.c (iq2000_scan_prologue): Add GDBARCH parameter.
+ (iq2000_frame_cache): Pass architecture to iq2000_scan_prologue.
+
+ * lm32-tdep.c (lm32_analyze_prologue): Add GDBARCH parameter.
+ (lm32_skip_prologue, lm32_frame_cache): Pass architecture to
+ lm32_analyze_prologue.
+
+ * m32r-tdep.c (decode_prologue): Add GDBARCH parameter.
+ (m32r_skip_prologue): Pass architecture to decode_prologue.
+
+ * m68hc11-tdep.c (m68hc11_analyze_instruction): Add GDBARCH parameter.
+ (m68hc11_scan_prologue): Pass architecture to
+ m68hc11_analyze_instruction.
+
+ * m68k-tdep.c (m68k_analyze_frame_setup): Add GDBARCH parameter.
+ (m68k_analyze_prologue): Pass architecture to
+ m68k_analyze_frame_setup.
+
+ * m88k-tdep.c (m88k_fetch_instruction): Add BYTE_ORDER parameter.
+ (m88k_analyze_prologue): Add GDBARCH parameter. Pass byte order
+ to m88k_fetch_instruction.
+ (m88k_skip_prologue): Pass architecture to m88k_analyze_prologue.
+ (m88k_frame_cache): Likewise.
+
+ * mep-tdep.c (mep_get_insn): Add GDBARCH parameter.
+ (mep_analyze_prologue): Pass architecture to mep_get_insn.
+
+ * mips-tdep.c (mips_fetch_instruction): Add GDBARCH parameter.
+ (mips32_next_pc): Pass architecture to mips_fetch_instruction.
+ (deal_with_atomic_sequence): Likewise.
+ (unpack_mips16): Add GDBARCH parameter, pass to mips_fetch_instruction.
+ (mips16_scan_prologue): Likewise.
+ (mips32_scan_prologue): Likewise.
+ (mips16_in_function_epilogue_p): Likewise.
+ (mips32_in_function_epilogue_p): Likewise.
+ (mips_about_to_return): Likewise.
+ (mips_insn16_frame_cache): Pass architecture to mips16_scan_prologue.
+ (mips_insn32_frame_cache): Pass architecture to mips32_scan_prologue.
+ (mips_skip_prologue): Pass architecture to mips16_scan_prologue
+ and mips32_scan_prologue.
+ (mips_in_function_epilogue_p): Pass architecture to
+ mips16_in_function_epilogue_p and
+ mips32_in_function_epilogue_p.
+ (heuristic_proc_start): Pass architecture to mips_fetch_instruction
+ and mips_about_to_return.
+ (mips_skip_mips16_trampoline_code): Pass architecture to
+ mips_fetch_instruction.
+ (fetch_mips_16): Add GDBARCH parameter.
+ (mips16_next_pc): Pass architecture to fetch_mips_16.
+ (extended_mips16_next_pc): Pass architecture to unpack_mips16 and
+ fetch_mips_16.
+
+ * objc-lang.c (read_objc_method, read_objc_methlist_nmethods,
+ read_objc_methlist_method, read_objc_object, read_objc_super,
+ read_objc_class): Add GDBARCH parameter.
+ (find_implementation_from_class): Add GDBARCH parameter, pass
+ to read_objc_class, read_objc_methlist_nmethods, and
+ read_objc_methlist_method.
+ (find_implementation): Add GDBARCH parameter, pass to
+ read_objc_object and find_implementation_from_class.
+ (resolve_msgsend, resolve_msgsend_stret): Pass architecture
+ to find_implementation.
+ (resolve_msgsend_super, resolve_msgsend_super_stret): Pass
+ architecture to read_objc_super and find_implementation_from_class.
+
+ * ppc64-linux-tdep.c (ppc64_desc_entry_point): Add GDBARCH parameter.
+ (ppc64_standard_linkage1_target, ppc64_standard_linkage2_target,
+ ppc64_standard_linkage3_target): Pass architecture to
+ ppc64_desc_entry_point.
+ * rs6000-tdep.c (bl_to_blrl_insn_p): Add BYTE_ORDER parameter.
+ (skip_prologue): Pass byte order to bl_to_blrl_insn_p.
+ (rs6000_fetch_instruction): Add GDBARCH parameter.
+ (rs6000_skip_stack_check): Add GDBARCH parameter, pass to
+ rs6000_fetch_instruction.
+ (skip_prologue): Pass architecture to rs6000_fetch_instruction.
+
+ * remote-mips.c (mips_store_word): Return old_contents as host
+ integer value instead of target bytes.
+
+ * s390-tdep.c (struct s390_prologue_data): Add BYTE_ORDER member.
+ (s390_analyze_prologue): Initialize it.
+ (extend_simple_arg): Add GDBARCH parameter.
+ (s390_push_dummy_call): Pass architecture to extend_simple_arg.
+
+ * scm-lang.c (scm_get_field): Add BYTE_ORDER parameter.
+ * scm-lang.h (scm_get_field): Add BYTE_ORDER parameter.
+ (SCM_CAR, SCM_CDR): Pass SCM_BYTE_ORDER to scm_get_field.
+ * scm-valprint.c (scm_scmval_print): Likewise.
+ (scm_scmlist_print, scm_ipruk, scm_scmval_print): Define
+ SCM_BYTE_ORDER.
+
+ * sh64-tdep.c (look_for_args_moves): Add GDBARCH parameter.
+ (sh64_skip_prologue_hard_way): Add GDBARCH parameter, pass to
+ look_for_args_moves.
+ (sh64_skip_prologue): Pass architecture to
+ sh64_skip_prologue_hard_way.
+ * sh-tdep.c (sh_analyze_prologue): Add GDBARCH parameter.
+ (sh_skip_prologue): Pass architecture to sh_analyze_prologue.
+ (sh_frame_cache): Likewise.
+
+ * solib-irix.c (extract_mips_address): Add GDBARCH parameter.
+ (fetch_lm_info, irix_current_sos, irix_open_symbol_file_object):
+ Pass architecture to extract_mips_address.
+
+ * sparc-tdep.h (sparc_fetch_wcookie): Add GDBARCH parameter.
+ * sparc-tdep.c (sparc_fetch_wcookie): Add GDBARCH parameter.
+ (sparc_supply_rwindow, sparc_collect_rwindow): Pass architecture
+ to sparc_fetch_wcookie.
+ (sparc32_frame_prev_register): Likewise.
+ * sparc64-tdep.c (sparc64_frame_prev_register): Likewise.
+ * sparc32nbsd-tdep.c (sparc32nbsd_sigcontext_saved_regs): Likewise.
+ * sparc64nbsd-tdep.c (sparc64nbsd_sigcontext_saved_regs): Likewise.
+
+ * spu-tdep.c (spu_analyze_prologue): Add GDBARCH parameter.
+ (spu_skip_prologue): Pass architecture to spu_analyze_prologue.
+ (spu_virtual_frame_pointer): Likewise.
+ (spu_frame_unwind_cache): Likewise.
+ (info_spu_mailbox_list): Add BYTE_ORER parameter.
+ (info_spu_mailbox_command): Pass byte order to info_spu_mailbox_list.
+ (info_spu_dma_cmdlist): Add BYTE_ORER parameter.
+ (info_spu_dma_command, info_spu_proxydma_command): Pass byte order
+ to info_spu_dma_cmdlist.
+
+ * symfile.c (read_target_long_array): Add GDBARCH parameter.
+ (simple_read_overlay_table, simple_read_overlay_region_table,
+ simple_overlay_update_1): Pass architecture to read_target_long_array.
+
+ * v850-tdep.c (v850_analyze_prologue): Add GDBARCH parameter.
+ (v850_frame_cache): Pass architecture to v850_analyze_prologue.
+
+ * xstormy16-tdep.c (xstormy16_analyze_prologue): Add GDBARCH
+ parameter.
+ (xstormy16_skip_prologue, xstormy16_frame_cache): Pass architecture
+ to xstormy16_analyze_prologue.
+ (xstormy16_resolve_jmp_table_entry): Add GDBARCH parameter.
+ (xstormy16_find_jmp_table_entry): Likewise.
+ (xstormy16_skip_trampoline_code): Pass architecture to
+ xstormy16_resolve_jmp_table_entry.
+ (xstormy16_pointer_to_address): Likewise.
+ (xstormy16_address_to_pointer): Pass architecture to
+ xstormy16_find_jmp_table_entry.
+
+ * xtensa-tdep.c (call0_track_op): Add GDBARCH parameter.
+ (call0_analyze_prologue): Add GDBARCH parameter, pass to
+ call0_track_op.
+ (call0_frame_cache): Pass architecture to call0_analyze_prologue.
+ (xtensa_skip_prologue): Likewise.
+
2009-07-02 Ulrich Weigand <uweigand@de.ibm.com>
* defs.h (strlen_paddr, paddr, paddr_nz): Remove.
val = allocate_value (type1);
store_unsigned_integer (value_contents_raw (val),
- TYPE_LENGTH (value_type (val)), v);
+ TYPE_LENGTH (value_type (val)),
+ gdbarch_byte_order (get_type_arch (type1)), v);
return val;
}
or 2) of a character. */
static int
-char_at (const gdb_byte *string, int i, int type_len)
+char_at (const gdb_byte *string, int i, int type_len,
+ enum bfd_endian byte_order)
{
if (type_len == 1)
return string[i];
else
- return (int) extract_unsigned_integer (string + 2 * i, 2);
+ return (int) extract_unsigned_integer (string + 2 * i, 2, byte_order);
}
/* Wrapper around memcpy to make it legal argument to ui_file_put */
unsigned int length, int force_ellipses, int type_len,
const struct value_print_options *options)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (elttype));
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
rep1 = i + 1;
reps = 1;
while (rep1 < length
- && char_at (string, rep1, type_len) == char_at (string, i,
- type_len))
+ && char_at (string, rep1, type_len, byte_order)
+ == char_at (string, i, type_len, byte_order))
{
rep1 += 1;
reps += 1;
in_quotes = 0;
}
fputs_filtered ("'", stream);
- ada_emit_char (char_at (string, i, type_len), elttype, stream, '\'',
- type_len);
+ ada_emit_char (char_at (string, i, type_len, byte_order),
+ elttype, stream, '\'', type_len);
fputs_filtered ("'", stream);
fprintf_filtered (stream, _(" <repeats %u times>"), reps);
i = rep1 - 1;
fputs_filtered ("\"", stream);
in_quotes = 1;
}
- ada_emit_char (char_at (string, i, type_len), elttype, stream, '"',
- type_len);
+ ada_emit_char (char_at (string, i, type_len, byte_order),
+ elttype, stream, '"', type_len);
things_printed += 1;
}
}
CORE_ADDR address, struct ui_file *stream, int recurse,
const struct value_print_options *options)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
struct type *elttype = TYPE_TARGET_TYPE (type);
unsigned int eltlen;
unsigned int len;
for (temp_len = 0;
(temp_len < len
&& temp_len < options->print_max
- && char_at (valaddr, temp_len, eltlen) != 0);
+ && char_at (valaddr, temp_len, eltlen, byte_order) != 0);
temp_len += 1);
len = temp_len;
}
*/
static long
-alpha_linux_sigtramp_offset_1 (CORE_ADDR pc)
+alpha_linux_sigtramp_offset_1 (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- switch (alpha_read_insn (pc))
+ switch (alpha_read_insn (gdbarch, pc))
{
case 0x47de0410: /* bis $30,$30,$16 */
case 0x47fe0410: /* bis $31,$30,$16 */
}
static LONGEST
-alpha_linux_sigtramp_offset (CORE_ADDR pc)
+alpha_linux_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
long i, off;
return -1;
/* Guess where we might be in the sequence. */
- off = alpha_linux_sigtramp_offset_1 (pc);
+ off = alpha_linux_sigtramp_offset_1 (gdbarch, pc);
if (off < 0)
return -1;
{
if (i == off)
continue;
- if (alpha_linux_sigtramp_offset_1 (pc + i) != i)
+ if (alpha_linux_sigtramp_offset_1 (gdbarch, pc + i) != i)
return -1;
}
}
static int
-alpha_linux_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alpha_linux_pc_in_sigtramp (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *func_name)
{
- return alpha_linux_sigtramp_offset (pc) >= 0;
+ return alpha_linux_sigtramp_offset (gdbarch, pc) >= 0;
}
static CORE_ADDR
alpha_linux_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
CORE_ADDR pc;
ULONGEST sp;
long off;
pc = get_frame_pc (this_frame);
sp = get_frame_register_unsigned (this_frame, ALPHA_SP_REGNUM);
- off = alpha_linux_sigtramp_offset (pc);
+ off = alpha_linux_sigtramp_offset (gdbarch, pc);
gdb_assert (off >= 0);
/* __NR_rt_sigreturn has a couple of structures on the stack. This is:
offsetof (struct rt_sigframe, uc.uc_mcontext);
*/
- if (alpha_read_insn (pc - off + 4) == 0x201f015f)
+ if (alpha_read_insn (gdbarch, pc - off + 4) == 0x201f015f)
return sp + 176;
/* __NR_sigreturn has the sigcontext structure at the top of the stack. */
#include "alpha-tdep.h"
static int
-alpha_osf1_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alpha_osf1_pc_in_sigtramp (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *func_name)
{
return (func_name != NULL && strcmp ("__sigtramp", func_name) == 0);
}
static CORE_ADDR
alpha_osf1_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct frame_info *next_frame = get_next_frame (this_frame);
struct frame_id next_id = null_frame_id;
if (next_frame != NULL)
next_id = get_frame_id (next_frame);
- return (read_memory_integer (next_id.stack_addr, 8));
+ return (read_memory_integer (next_id.stack_addr, 8, byte_order));
}
static void
floating point and 32-bit integers. */
static void
-alpha_lds (void *out, const void *in)
+alpha_lds (struct gdbarch *gdbarch, void *out, const void *in)
{
- ULONGEST mem = extract_unsigned_integer (in, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ ULONGEST mem = extract_unsigned_integer (in, 4, byte_order);
ULONGEST frac = (mem >> 0) & 0x7fffff;
ULONGEST sign = (mem >> 31) & 1;
ULONGEST exp_msb = (mem >> 30) & 1;
}
reg = (sign << 63) | (exp << 52) | (frac << 29);
- store_unsigned_integer (out, 8, reg);
+ store_unsigned_integer (out, 8, byte_order, reg);
}
/* Similarly, this represents exactly the conversion performed by
the STS instruction. */
static void
-alpha_sts (void *out, const void *in)
+alpha_sts (struct gdbarch *gdbarch, void *out, const void *in)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST reg, mem;
- reg = extract_unsigned_integer (in, 8);
+ reg = extract_unsigned_integer (in, 8, byte_order);
mem = ((reg >> 32) & 0xc0000000) | ((reg >> 29) & 0x3fffffff);
- store_unsigned_integer (out, 4, mem);
+ store_unsigned_integer (out, 4, byte_order, mem);
}
/* The alpha needs a conversion between register and memory format if the
switch (TYPE_LENGTH (valtype))
{
case 4:
- alpha_sts (out, in);
+ alpha_sts (get_frame_arch (frame), out, in);
break;
default:
error (_("Cannot retrieve value from floating point register"));
switch (TYPE_LENGTH (valtype))
{
case 4:
- alpha_lds (out, in);
+ alpha_lds (get_frame_arch (frame), out, in);
break;
default:
error (_("Cannot store value in floating point register"));
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
int accumulate_size = struct_return ? 8 : 0;
struct alpha_arg
write_memory (sp + offset - sizeof(arg_reg_buffer), contents, len);
}
if (struct_return)
- store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE, struct_addr);
+ store_unsigned_integer (arg_reg_buffer, ALPHA_REGISTER_SIZE,
+ byte_order, struct_addr);
/* Load the argument registers. */
for (i = 0; i < required_arg_regs; i++)
alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int length = TYPE_LENGTH (valtype);
gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
ULONGEST l;
{
case 4:
regcache_cooked_read (regcache, ALPHA_FP0_REGNUM, raw_buffer);
- alpha_sts (valbuf, raw_buffer);
+ alpha_sts (gdbarch, valbuf, raw_buffer);
break;
case 8:
default:
/* Assume everything else degenerates to an integer. */
regcache_cooked_read_unsigned (regcache, ALPHA_V0_REGNUM, &l);
- store_unsigned_integer (valbuf, length, l);
+ store_unsigned_integer (valbuf, length, byte_order, l);
break;
}
}
switch (length)
{
case 4:
- alpha_lds (raw_buffer, valbuf);
+ alpha_lds (gdbarch, raw_buffer, valbuf);
regcache_cooked_write (regcache, ALPHA_FP0_REGNUM, raw_buffer);
break;
/* Read an instruction from memory at PC, looking through breakpoints. */
unsigned int
-alpha_read_insn (CORE_ADDR pc)
+alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[ALPHA_INSN_SIZE];
int status;
status = target_read_memory (pc, buf, sizeof (buf));
if (status)
memory_error (status, pc);
- return extract_unsigned_integer (buf, sizeof (buf));
+ return extract_unsigned_integer (buf, sizeof (buf), byte_order);
}
/* To skip prologues, I use this predicate. Returns either PC itself
or in the gcc frame. */
for (offset = 0; offset < 100; offset += ALPHA_INSN_SIZE)
{
- inst = alpha_read_insn (pc + offset);
+ inst = alpha_read_insn (gdbarch, pc + offset);
if ((inst & 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */
continue;
static int
alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR jb_addr;
gdb_byte raw_buffer[ALPHA_REGISTER_SIZE];
raw_buffer, tdep->jb_elt_size))
return 0;
- *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size);
+ *pc = extract_unsigned_integer (raw_buffer, tdep->jb_elt_size, byte_order);
return 1;
}
{
int offset;
code_addr = get_frame_pc (this_frame);
- offset = tdep->dynamic_sigtramp_offset (code_addr);
+ offset = tdep->dynamic_sigtramp_offset (gdbarch, code_addr);
if (offset >= 0)
code_addr -= offset;
else
/* Otherwise we should be in a signal frame. */
find_pc_partial_function (pc, &name, NULL, NULL);
- if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (pc, name))
+ if (gdbarch_tdep (gdbarch)->pc_in_sigtramp (gdbarch, pc, name))
return 1;
return 0;
nops, since this usually indicates padding between functions. */
for (pc -= ALPHA_INSN_SIZE; pc >= fence; pc -= ALPHA_INSN_SIZE)
{
- unsigned int insn = alpha_read_insn (pc);
+ unsigned int insn = alpha_read_insn (gdbarch, pc);
switch (insn)
{
case 0: /* invalid insn */
for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += ALPHA_INSN_SIZE)
{
- unsigned int word = alpha_read_insn (cur_pc);
+ unsigned int word = alpha_read_insn (gdbarch, cur_pc);
if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */
{
{
while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80))
{
- unsigned int word = alpha_read_insn (cur_pc);
+ unsigned int word = alpha_read_insn (gdbarch, cur_pc);
if ((word & 0xfc1f0000) == 0xb41e0000) /* stq reg,n($sp) */
{
static CORE_ADDR
alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
unsigned int insn;
unsigned int op;
int regno;
int offset;
LONGEST rav;
- insn = alpha_read_insn (pc);
+ insn = alpha_read_insn (gdbarch, pc);
/* Opcode is top 6 bits. */
op = (insn >> 26) & 0x3f;
case 0x33: /* FBLE */
case 0x32: /* FBLT */
case 0x35: /* FBNE */
- regno += gdbarch_fp0_regnum (get_frame_arch (frame));
+ regno += gdbarch_fp0_regnum (gdbarch);
}
rav = get_frame_register_signed (frame, regno);
/* If PC is inside a dynamically-generated signal trampoline function
(i.e. one copied onto the user stack at run-time), return how many
bytes PC is beyond the start of that function. Otherwise, return -1. */
- LONGEST (*dynamic_sigtramp_offset) (CORE_ADDR);
+ LONGEST (*dynamic_sigtramp_offset) (struct gdbarch *, CORE_ADDR);
/* Translate a signal handler stack base address into the address of
the sigcontext structure for that signal handler. */
/* NOTE: cagney/2004-04-30: Do not copy/clone this code. Instead
look at tramp-frame.h and other simplier per-architecture
sigtramp unwinders. */
- int (*pc_in_sigtramp) (CORE_ADDR pc, char *name);
+ int (*pc_in_sigtramp) (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
/* If TYPE will be returned in memory, return true. */
int (*return_in_memory) (struct type *type);
size_t jb_elt_size; /* And the size of each entry in the buf. */
};
-extern unsigned int alpha_read_insn (CORE_ADDR pc);
+extern unsigned int alpha_read_insn (struct gdbarch *gdbarch, CORE_ADDR pc);
extern int alpha_software_single_step (struct frame_info *frame);
extern CORE_ADDR alpha_after_prologue (CORE_ADDR pc);
CORE_ADDR alphafbsd_sigtramp_end = 0x11ffffe0;
static int
-alphafbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alphafbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *func_name)
{
return (pc >= alphafbsd_sigtramp_start && pc < alphafbsd_sigtramp_end);
}
static LONGEST
-alphafbsd_sigtramp_offset (CORE_ADDR pc)
+alphafbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
return pc - alphafbsd_sigtramp_start;
}
#define RETCODE_SIZE (RETCODE_NWORDS * 4)
static LONGEST
-alphanbsd_sigtramp_offset (CORE_ADDR pc)
+alphanbsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned char ret[RETCODE_SIZE], w[4];
LONGEST off;
}
static int
-alphanbsd_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
+alphanbsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *func_name)
{
return (nbsd_pc_in_sigtramp (pc, func_name)
- || alphanbsd_sigtramp_offset (pc) >= 0);
+ || alphanbsd_sigtramp_offset (gdbarch, pc) >= 0);
}
static CORE_ADDR
static const int alphaobsd_page_size = 8192;
static LONGEST
-alphaobsd_sigtramp_offset (CORE_ADDR pc)
+alphaobsd_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
return (pc & (alphaobsd_page_size - 1));
}
static int
-alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
+alphaobsd_pc_in_sigtramp (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
CORE_ADDR start_pc = (pc & ~(alphaobsd_page_size - 1));
unsigned insn;
return 0;
/* Check for "". */
- insn = alpha_read_insn (start_pc + 5 * ALPHA_INSN_SIZE);
+ insn = alpha_read_insn (gdbarch, start_pc + 5 * ALPHA_INSN_SIZE);
if (insn != 0x201f0067)
return 0;
/* Check for "". */
- insn = alpha_read_insn (start_pc + 6 * ALPHA_INSN_SIZE);
+ insn = alpha_read_insn (gdbarch, start_pc + 6 * ALPHA_INSN_SIZE);
if (insn != 0x00000083)
return 0;
static CORE_ADDR
alphaobsd_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
CORE_ADDR pc = get_frame_pc (this_frame);
- if (alphaobsd_sigtramp_offset (pc) < 3 * ALPHA_INSN_SIZE)
+ if (alphaobsd_sigtramp_offset (gdbarch, pc) < 3 * ALPHA_INSN_SIZE)
{
/* On entry, a pointer the `struct sigcontext' is passed in %a2. */
return get_frame_register_unsigned (this_frame, ALPHA_A0_REGNUM + 2);
}
- else if (alphaobsd_sigtramp_offset (pc) < 4 * ALPHA_INSN_SIZE)
+ else if (alphaobsd_sigtramp_offset (gdbarch, pc) < 4 * ALPHA_INSN_SIZE)
{
/* It is stored on the stack Before calling the signal handler. */
CORE_ADDR sp;
static CORE_ADDR
amd64_linux_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
gdb_byte buf[8];
get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 8);
+ sp = extract_unsigned_integer (buf, 8, byte_order);
/* The sigcontext structure is part of the user context. A pointer
to the user context is passed as the third argument to the signal
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[8];
/* Pass arguments. */
/* Pass "hidden" argument". */
if (struct_return)
{
- store_unsigned_integer (buf, 8, struct_addr);
+ store_unsigned_integer (buf, 8, byte_order, struct_addr);
regcache_cooked_write (regcache, AMD64_RDI_REGNUM, buf);
}
/* Store return address. */
sp -= 8;
- store_unsigned_integer (buf, 8, bp_addr);
+ store_unsigned_integer (buf, 8, byte_order, bp_addr);
write_memory (sp, buf, 8);
/* Finally, update the stack pointer... */
- store_unsigned_integer (buf, 8, sp);
+ store_unsigned_integer (buf, 8, byte_order, sp);
regcache_cooked_write (regcache, AMD64_RSP_REGNUM, buf);
/* ...and fake a frame pointer. */
fixup_riprel (struct gdbarch *gdbarch, struct displaced_step_closure *dsc,
CORE_ADDR from, CORE_ADDR to, struct regcache *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const struct amd64_insn *insn_details = &dsc->insn_details;
int modrm_offset = insn_details->modrm_offset;
gdb_byte *insn = insn_details->raw_insn + modrm_offset;
++insn;
/* Compute the rip-relative address. */
- disp = extract_signed_integer (insn, sizeof (int32_t));
+ disp = extract_signed_integer (insn, sizeof (int32_t), byte_order);
insn_length = amd64_insn_length (gdbarch, dsc->insn_buf, dsc->max_len, from);
rip_base = from + insn_length;
CORE_ADDR from, CORE_ADDR to,
struct regcache *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* The offset we applied to the instruction's address. */
ULONGEST insn_offset = to - from;
gdb_byte *insn = dsc->insn_buf;
const ULONGEST retaddr_len = 8;
regcache_cooked_read_unsigned (regs, AMD64_RSP_REGNUM, &rsp);
- retaddr = read_memory_unsigned_integer (rsp, retaddr_len);
+ retaddr = read_memory_unsigned_integer (rsp, retaddr_len, byte_order);
retaddr = (retaddr - insn_offset) & 0xffffffffUL;
- write_memory_unsigned_integer (rsp, retaddr_len, retaddr);
+ write_memory_unsigned_integer (rsp, retaddr_len, byte_order, retaddr);
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog,
to have no prologue and thus no valid frame pointer in %rbp. */
static CORE_ADDR
-amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+amd64_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR current_pc,
struct amd64_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
static gdb_byte proto[3] = { 0x48, 0x89, 0xe5 }; /* movq %rsp, %rbp */
gdb_byte buf[3];
gdb_byte op;
pc = amd64_analyze_stack_align (pc, current_pc, cache);
- op = read_memory_unsigned_integer (pc, 1);
+ op = read_memory_unsigned_integer (pc, 1, byte_order);
if (op == 0x55) /* pushq %rbp */
{
CORE_ADDR pc;
amd64_init_frame_cache (&cache);
- pc = amd64_analyze_prologue (start_pc, 0xffffffffffffffffLL, &cache);
+ pc = amd64_analyze_prologue (gdbarch, start_pc, 0xffffffffffffffffLL,
+ &cache);
if (cache.frameless_p)
return start_pc;
static struct amd64_frame_cache *
amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct amd64_frame_cache *cache;
gdb_byte buf[8];
int i;
cache->pc = get_frame_func (this_frame);
if (cache->pc != 0)
- amd64_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+ amd64_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+ cache);
if (cache->saved_sp_reg != -1)
{
/* Stack pointer has been saved. */
get_frame_register (this_frame, cache->saved_sp_reg, buf);
- cache->saved_sp = extract_unsigned_integer(buf, 8);
+ cache->saved_sp = extract_unsigned_integer(buf, 8, byte_order);
}
if (cache->frameless_p)
else
{
get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 8) + cache->sp_offset;
+ cache->base = extract_unsigned_integer (buf, 8, byte_order)
+ + cache->sp_offset;
}
}
else
{
get_frame_register (this_frame, AMD64_RBP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 8);
+ cache->base = extract_unsigned_integer (buf, 8, byte_order);
}
/* Now that we have the base address for the stack frame we can
static struct amd64_frame_cache *
amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct amd64_frame_cache *cache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
CORE_ADDR addr;
gdb_byte buf[8];
int i;
cache = amd64_alloc_frame_cache ();
get_frame_register (this_frame, AMD64_RSP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 8) - 8;
+ cache->base = extract_unsigned_integer (buf, 8, byte_order) - 8;
addr = tdep->sigcontext_addr (this_frame);
gdb_assert (tdep->sc_reg_offset);
amd64obsd_supply_uthread (struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
CORE_ADDR sp = 0;
gdb_byte buf[8];
int offset;
/* Fetch stack pointer from thread structure. */
- sp = read_memory_unsigned_integer (sp_addr, 8);
+ sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
/* Adjust the stack pointer such that it looks as if we just
returned from _thread_machdep_switch. */
offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
- store_unsigned_integer (buf, 8, sp + offset);
+ store_unsigned_integer (buf, 8, byte_order, sp + offset);
regcache_raw_supply (regcache, AMD64_RSP_REGNUM, buf);
}
/* Fetch stack pointer from thread structure (if we didn't
do so already). */
if (sp == 0)
- sp = read_memory_unsigned_integer (sp_addr, 8);
+ sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
/* Read the saved register from the stack frame. */
read_memory (sp + amd64obsd_uthread_reg_offset[i], buf, 8);
amd64obsd_collect_uthread (const struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp_addr = addr + AMD64OBSD_UTHREAD_RSP_OFFSET;
CORE_ADDR sp = 0;
gdb_byte buf[8];
stored into the thread structure. */
offset = amd64obsd_uthread_reg_offset[AMD64_RIP_REGNUM] + 8;
regcache_raw_collect (regcache, AMD64_RSP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 8) - offset;
+ sp = extract_unsigned_integer (buf, 8, byte_order) - offset;
/* Store the stack pointer. */
- write_memory_unsigned_integer (sp_addr, 8, sp);
+ write_memory_unsigned_integer (sp_addr, 8, byte_order, sp);
/* The stack pointer was (potentially) modified. Make sure we
build a proper stack frame. */
/* Fetch stack pointer from thread structure (if we didn't
calculate it already). */
if (sp == 0)
- sp = read_memory_unsigned_integer (sp_addr, 8);
+ sp = read_memory_unsigned_integer (sp_addr, 8, byte_order);
/* Write the register into the stack frame. */
regcache_raw_collect (regcache, i, buf);
static struct trad_frame_cache *
amd64obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct trad_frame_cache *cache;
CORE_ADDR func, sp, addr;
ULONGEST cs;
/* Read %cs from trap frame. */
addr += amd64obsd_tf_reg_offset[AMD64_CS_REGNUM];
- cs = read_memory_unsigned_integer (addr, 8);
+ cs = read_memory_unsigned_integer (addr, 8, byte_order);
if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
{
/* Trap from user space; terminate backtrace. */
}
int
-generic_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
return 0;
}
extern CORE_ADDR generic_skip_solib_resolver (struct gdbarch *gdbarch,
CORE_ADDR pc);
-extern int generic_in_solib_return_trampoline (CORE_ADDR pc, char *name);
+extern int generic_in_solib_return_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name);
extern int generic_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc);
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
- ULONGEST uc_flags = read_memory_unsigned_integer (sp, 4);
+ ULONGEST uc_flags = read_memory_unsigned_integer (sp, 4, byte_order);
if (uc_flags == ARM_NEW_SIGFRAME_MAGIC)
arm_linux_sigtramp_cache (this_frame, this_cache, func,
struct trad_frame_cache *this_cache,
CORE_ADDR func)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp = get_frame_register_unsigned (this_frame, ARM_SP_REGNUM);
- ULONGEST pinfo = read_memory_unsigned_integer (sp, 4);
+ ULONGEST pinfo = read_memory_unsigned_integer (sp, 4, byte_order);
if (pinfo == sp + ARM_OLD_RT_SIGFRAME_SIGINFO)
arm_linux_sigtramp_cache (this_frame, this_cache, func,
struct regcache *regcache,
int regnum, const void *gregs_buf, size_t len)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const gdb_byte *gregs = gregs_buf;
int regno;
CORE_ADDR reg_pc;
{
reg_pc = extract_unsigned_integer (gregs
+ INT_REGISTER_SIZE * ARM_PC_REGNUM,
- INT_REGISTER_SIZE);
- reg_pc = gdbarch_addr_bits_remove (get_regcache_arch (regcache), reg_pc);
- store_unsigned_integer (pc_buf, INT_REGISTER_SIZE, reg_pc);
+ INT_REGISTER_SIZE, byte_order);
+ reg_pc = gdbarch_addr_bits_remove (gdbarch, reg_pc);
+ store_unsigned_integer (pc_buf, INT_REGISTER_SIZE, byte_order, reg_pc);
regcache_raw_supply (regcache, ARM_PC_REGNUM, pc_buf);
}
}
#define MSYMBOL_IS_SPECIAL(msym) \
MSYMBOL_TARGET_FLAG_1 (msym)
-/* Macros for swapping shorts and ints. In the unlikely case that anybody else needs these,
- move to a general header. (A better solution might be to define memory read routines that
- know whether they are reading code or data.) */
-
-#define SWAP_SHORT(x) \
- ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8));
-
-#define SWAP_INT(x) \
- ( ((x & 0xff000000) >> 24) \
- | ((x & 0x00ff0000) >> 8) \
- | ((x & 0x0000ff00) << 8) \
- | ((x & 0x000000ff) << 24))
-
/* Per-objfile data used for mapping symbols. */
static const struct objfile_data *arm_objfile_data_key;
CORE_ADDR start, CORE_ADDR limit,
struct arm_prologue_cache *cache)
{
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
int i;
pv_t regs[16];
struct pv_area *stack;
{
unsigned short insn;
- insn = read_memory_unsigned_integer (start, 2);
-
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- insn = SWAP_SHORT (insn);
+ insn = read_memory_unsigned_integer (start, 2, byte_order_for_code);
if ((insn & 0xfe00) == 0xb400) /* push { rlist } */
{
static CORE_ADDR
arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
unsigned long inst;
CORE_ADDR skip_pc;
CORE_ADDR func_addr, limit_pc;
for (skip_pc = pc; skip_pc < limit_pc; skip_pc += 4)
{
- inst = read_memory_unsigned_integer (skip_pc, 4);
-
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- inst = SWAP_INT (inst);
+ inst = read_memory_unsigned_integer (skip_pc, 4, byte_order_for_code);
/* "mov ip, sp" is no longer a required part of the prologue. */
if (inst == 0xe1a0c00d) /* mov ip, sp */
struct arm_prologue_cache *cache)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
int regno;
CORE_ADDR prologue_start, prologue_end, current_pc;
CORE_ADDR prev_pc = get_frame_pc (this_frame);
LONGEST return_value;
frame_loc = get_frame_register_unsigned (this_frame, ARM_FP_REGNUM);
- if (!safe_read_memory_integer (frame_loc, 4, &return_value))
+ if (!safe_read_memory_integer (frame_loc, 4, byte_order, &return_value))
return;
else
{
current_pc < prologue_end;
current_pc += 4)
{
- unsigned int insn = read_memory_unsigned_integer (current_pc, 4);
-
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- insn = SWAP_INT (insn);
+ unsigned int insn
+ = read_memory_unsigned_integer (current_pc, 4, byte_order_for_code);
if (insn == 0xe1a0c00d) /* mov ip, sp */
{
struct value **args, CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argnum;
int argreg;
int nstack;
&& target_type != NULL
&& TYPE_CODE_FUNC == TYPE_CODE (target_type))
{
- CORE_ADDR regval = extract_unsigned_integer (val, len);
+ CORE_ADDR regval = extract_unsigned_integer (val, len, byte_order);
if (arm_pc_is_thumb (regval))
{
val = alloca (len);
- store_unsigned_integer (val, len, MAKE_THUMB_ADDR (regval));
+ store_unsigned_integer (val, len, byte_order,
+ MAKE_THUMB_ADDR (regval));
}
}
{
/* The argument is being passed in a general purpose
register. */
- CORE_ADDR regval = extract_unsigned_integer (val, partial_len);
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ CORE_ADDR regval
+ = extract_unsigned_integer (val, partial_len, byte_order);
+ if (byte_order == BFD_ENDIAN_BIG)
regval <<= (INT_REGISTER_SIZE - partial_len) * 8;
if (arm_debug)
fprintf_unfiltered (gdb_stdlog, "arg %d in %s = 0x%s\n",
thumb_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
unsigned long pc_val = ((unsigned long) pc) + 4; /* PC after prefetch */
- unsigned short inst1 = read_memory_unsigned_integer (pc, 2);
+ unsigned short inst1;
CORE_ADDR nextpc = pc + 2; /* default is next instruction */
unsigned long offset;
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- inst1 = SWAP_SHORT (inst1);
+ inst1 = read_memory_unsigned_integer (pc, 2, byte_order_for_code);
if ((inst1 & 0xff00) == 0xbd00) /* pop {rlist, pc} */
{
all of the other registers. */
offset = bitcount (bits (inst1, 0, 7)) * INT_REGISTER_SIZE;
sp = get_frame_register_unsigned (frame, ARM_SP_REGNUM);
- nextpc = (CORE_ADDR) read_memory_unsigned_integer (sp + offset, 4);
+ nextpc = read_memory_unsigned_integer (sp + offset, 4, byte_order);
nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
if (nextpc == pc)
error (_("Infinite loop detected"));
}
else if ((inst1 & 0xf800) == 0xf000) /* long branch with link, and blx */
{
- unsigned short inst2 = read_memory_unsigned_integer (pc + 2, 2);
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- inst2 = SWAP_SHORT (inst2);
+ unsigned short inst2;
+ inst2 = read_memory_unsigned_integer (pc + 2, 2, byte_order_for_code);
offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1);
nextpc = pc_val + offset;
/* For BLX make sure to clear the low bits. */
arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ enum bfd_endian byte_order_for_code = gdbarch_byte_order_for_code (gdbarch);
unsigned long pc_val;
unsigned long this_instr;
unsigned long status;
return thumb_get_next_pc (frame, pc);
pc_val = (unsigned long) pc;
- this_instr = read_memory_unsigned_integer (pc, 4);
-
- if (gdbarch_byte_order_for_code (gdbarch) != gdbarch_byte_order (gdbarch))
- this_instr = SWAP_INT (this_instr);
+ this_instr = read_memory_unsigned_integer (pc, 4, byte_order_for_code);
status = get_frame_register_unsigned (frame, ARM_PS_REGNUM);
nextpc = (CORE_ADDR) (pc_val + 4); /* Default case */
base -= offset;
}
nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base,
- 4);
+ 4, byte_order);
nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
nextpc =
(CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val
+ offset),
- 4);
+ 4, byte_order);
}
nextpc = gdbarch_addr_bits_remove
(gdbarch, nextpc);
gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regs);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
if (TYPE_CODE_FLT == TYPE_CODE (type))
{
store_unsigned_integer (valbuf,
(len > INT_REGISTER_SIZE
? INT_REGISTER_SIZE : len),
- tmp);
+ byte_order, tmp);
len -= INT_REGISTER_SIZE;
valbuf += INT_REGISTER_SIZE;
}
const gdb_byte *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regs);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
{
bfd_byte tmpbuf[INT_REGISTER_SIZE];
LONGEST val = unpack_long (type, valbuf);
- store_signed_integer (tmpbuf, INT_REGISTER_SIZE, val);
+ store_signed_integer (tmpbuf, INT_REGISTER_SIZE, byte_order, val);
regcache_cooked_write (regs, ARM_A1_REGNUM, tmpbuf);
}
else
static int
arm_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR jb_addr;
char buf[INT_REGISTER_SIZE];
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
jb_addr = get_frame_register_unsigned (frame, ARM_A1_REGNUM);
INT_REGISTER_SIZE))
return 0;
- *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE);
+ *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE, byte_order);
return 1;
}
#include "target.h"
#include "solib.h"
#include "solib-target.h"
+#include "frame.h"
#include "gdb_string.h"
static CORE_ADDR
arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST indirect;
struct minimal_symbol *indsym;
char *symname;
.dw __imp_<func> */
if (pc == 0
- || read_memory_unsigned_integer (pc + 0, 4) != 0xe59fc000
- || read_memory_unsigned_integer (pc + 4, 4) != 0xe59cf000)
+ || read_memory_unsigned_integer (pc + 0, 4, byte_order) != 0xe59fc000
+ || read_memory_unsigned_integer (pc + 4, 4, byte_order) != 0xe59cf000)
return 0;
- indirect = read_memory_unsigned_integer (pc + 8, 4);
+ indirect = read_memory_unsigned_integer (pc + 8, 4, byte_order);
if (indirect == 0)
return 0;
if (symname == NULL || strncmp (symname, "__imp_", 6) != 0)
return 0;
- next_pc = read_memory_unsigned_integer (indirect, 4);
+ next_pc = read_memory_unsigned_integer (indirect, 4, byte_order);
if (next_pc != 0)
return next_pc;
{
const int sizeof_auxv_field = gdbarch_ptr_bit (target_gdbarch)
/ TARGET_CHAR_BIT;
+ const enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
gdb_byte *ptr = *readptr;
if (endptr == ptr)
if (endptr - ptr < sizeof_auxv_field * 2)
return -1;
- *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+ *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
ptr += sizeof_auxv_field;
- *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
+ *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
ptr += sizeof_auxv_field;
*readptr = ptr;
#undef XMALLOC
#define XMALLOC(TYPE) ((TYPE*) xmalloc (sizeof (TYPE)))
-#undef EXTRACT_INSN
-#define EXTRACT_INSN(addr) extract_unsigned_integer(addr,2)
-
/* Constants: prefixed with AVR_ to avoid name space clashes */
enum
avr_address_to_pointer (struct gdbarch *gdbarch,
struct type *type, gdb_byte *buf, CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* Is it a code address? */
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
|| TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD)
{
- store_unsigned_integer (buf, TYPE_LENGTH (type),
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
avr_convert_iaddr_to_raw (addr >> 1));
}
else
{
/* Strip off any upper segment bits. */
- store_unsigned_integer (buf, TYPE_LENGTH (type),
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order,
avr_convert_saddr_to_raw (addr));
}
}
avr_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
- CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ CORE_ADDR addr
+ = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
/* Is it a code address? */
if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC
types. */
static CORE_ADDR
-avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
+avr_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc_beg, CORE_ADDR pc_end,
struct avr_unwind_cache *info)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
unsigned short insn;
int scan_stage = 0;
0xcd, 0xbf /* out __SP_L__,r28 */
};
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
/* ldi r28,lo8(<RAM_ADDR> - <LOCALS_SIZE>) */
if ((insn & 0xf0f0) == 0xe0c0)
{
locals = (insn & 0xf) | ((insn & 0x0f00) >> 4);
- insn = EXTRACT_INSN (&prologue[vpc + 2]);
+ insn = extract_unsigned_integer (&prologue[vpc + 2], 2, byte_order);
/* ldi r29,hi8(<RAM_ADDR> - <LOCALS_SIZE>) */
if ((insn & 0xf0f0) == 0xe0d0)
{
if (len < 10)
break;
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
/* ldi r26,<LOCALS_SIZE> */
if ((insn & 0xf0f0) != 0xe0a0)
break;
loc_size = (insn & 0xf) | ((insn & 0x0f00) >> 4);
pc_offset += 2;
- insn = EXTRACT_INSN (&prologue[vpc + 2]);
+ insn = extract_unsigned_integer (&prologue[vpc + 2], 2, byte_order);
/* ldi r27,<LOCALS_SIZE> / 256 */
if ((insn & 0xf0f0) != 0xe0b0)
break;
loc_size |= ((insn & 0xf) | ((insn & 0x0f00) >> 4)) << 8;
pc_offset += 2;
- insn = EXTRACT_INSN (&prologue[vpc + 4]);
+ insn = extract_unsigned_integer (&prologue[vpc + 4], 2, byte_order);
/* ldi r30,pm_lo8(.L_foo_body) */
if ((insn & 0xf0f0) != 0xe0e0)
break;
body_addr = (insn & 0xf) | ((insn & 0x0f00) >> 4);
pc_offset += 2;
- insn = EXTRACT_INSN (&prologue[vpc + 6]);
+ insn = extract_unsigned_integer (&prologue[vpc + 6], 2, byte_order);
/* ldi r31,pm_hi8(.L_foo_body) */
if ((insn & 0xf0f0) != 0xe0f0)
break;
if (!msymbol)
break;
- insn = EXTRACT_INSN (&prologue[vpc + 8]);
+ insn = extract_unsigned_integer (&prologue[vpc + 8], 2, byte_order);
/* rjmp __prologue_saves__+RRR */
if ((insn & 0xf000) == 0xc000)
{
{
/* Extract absolute PC address from JMP */
i = (((insn & 0x1) | ((insn & 0x1f0) >> 3) << 16)
- | (EXTRACT_INSN (&prologue[vpc + 10]) & 0xffff));
+ | (extract_unsigned_integer (&prologue[vpc + 10], 2, byte_order)
+ & 0xffff));
/* Convert address to byte addressable mode */
i *= 2;
for (; vpc < len; vpc += 2)
{
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
if ((insn & 0xfe0f) == 0x920f) /* push rXX */
{
/* Bits 4-9 contain a mask for registers R0-R32. */
0xcd, 0xbf /* out 0x3d,r28 ; SPL */
};
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
vpc += 2;
if ((insn & 0xff30) == 0x9720) /* sbiw r28,XXX */
locals_size = (insn & 0xf) | ((insn & 0xc0) >> 2);
else if ((insn & 0xf0f0) == 0x50c0) /* subi r28,lo8(XX) */
{
locals_size = (insn & 0xf) | ((insn & 0xf00) >> 4);
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
vpc += 2;
locals_size += ((insn & 0xf) | ((insn & 0xf00) >> 4) << 8);
}
for (; vpc < len; vpc += 2)
{
- insn = EXTRACT_INSN (&prologue[vpc]);
+ insn = extract_unsigned_integer (&prologue[vpc], 2, byte_order);
if ((insn & 0xff00) == 0x0100) /* movw rXX, rYY */
continue;
else if ((insn & 0xfc00) == 0x2c00) /* mov rXX, rYY */
prologue and possibly skip over moving arguments passed via registers
to other registers. */
- prologue_end = avr_scan_prologue (func_addr, func_end, &info);
+ prologue_end = avr_scan_prologue (gdbarch, func_addr, func_end, &info);
if (info.prologue_type == AVR_PROLOGUE_NONE)
return pc;
avr_extract_return_value (struct type *type, struct regcache *regcache,
gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST r24, r25;
ULONGEST c;
int len;
if (TYPE_LENGTH (type) == 1)
{
regcache_cooked_read_unsigned (regcache, 24, &c);
- store_unsigned_integer (valbuf, 1, c);
+ store_unsigned_integer (valbuf, 1, byte_order, c);
}
else
{
start_pc = get_frame_func (this_frame);
current_pc = get_frame_pc (this_frame);
if ((start_pc > 0) && (start_pc <= current_pc))
- avr_scan_prologue (start_pc, current_pc, info);
+ avr_scan_prologue (get_frame_arch (this_frame),
+ start_pc, current_pc, info);
if ((info->prologue_type != AVR_PROLOGUE_NONE)
&& (info->prologue_type != AVR_PROLOGUE_MAIN))
avr_frame_prev_register (struct frame_info *this_frame,
void **this_prologue_cache, int regnum)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct avr_unwind_cache *info
= avr_frame_unwind_cache (this_frame, this_prologue_cache);
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
unsigned char buf[2];
CORE_ADDR return_pc = avr_convert_iaddr_to_raw (bp_addr);
if (len & 1)
regnum--;
- val = extract_unsigned_integer (contents, len);
+ val = extract_unsigned_integer (contents, len, byte_order);
for (j=0; j<len; j++)
{
regcache_cooked_write_unsigned (regcache, regnum--,
static void
bsd_uthread_check_magic (CORE_ADDR addr)
{
- ULONGEST magic = read_memory_unsigned_integer (addr, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ ULONGEST magic = read_memory_unsigned_integer (addr, 4, byte_order);
if (magic != BSD_UTHREAD_PTHREAD_MAGIC)
error (_("Bad magic"));
static int
bsd_uthread_lookup_offset (const char *name, struct objfile *objfile)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR addr;
addr = bsd_uthread_lookup_address (name, objfile);
if (addr == 0)
return 0;
- return read_memory_unsigned_integer (addr, 4);
+ return read_memory_unsigned_integer (addr, 4, byte_order);
}
static CORE_ADDR
bsd_uthread_wait (struct target_ops *ops,
ptid_t ptid, struct target_waitstatus *status, int options)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR addr;
struct target_ops *beneath = find_target_beneath (ops);
been read from the wrong virtual memory image. */
if (target_read_memory (addr, buf, 4) == 0)
{
- ULONGEST magic = extract_unsigned_integer (buf, 4);
+ ULONGEST magic = extract_unsigned_integer (buf, 4, byte_order);
if (magic == BSD_UTHREAD_PTHREAD_MAGIC)
ptid = ptid_build (ptid_get_pid (ptid), 0, addr);
}
static int
bsd_uthread_thread_alive (struct target_ops *ops, ptid_t ptid)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct target_ops *beneath = find_target_beneath (ops);
CORE_ADDR addr = ptid_get_tid (inferior_ptid);
bsd_uthread_check_magic (addr);
- state = read_memory_unsigned_integer (addr + offset, 4);
+ state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
if (state == BSD_UTHREAD_PS_DEAD)
return 0;
}
static char *
bsd_uthread_extra_thread_info (struct thread_info *info)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR addr = ptid_get_tid (info->ptid);
if (addr != 0)
int offset = bsd_uthread_thread_state_offset;
ULONGEST state;
- state = read_memory_unsigned_integer (addr + offset, 4);
+ state = read_memory_unsigned_integer (addr + offset, 4, byte_order);
if (state < ARRAY_SIZE (bsd_uthread_state))
return bsd_uthread_state[state];
}
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type->builtin_decfloat;
- decimal_from_string (putithere->typed_val_decfloat.val, 4, p);
+ decimal_from_string (putithere->typed_val_decfloat.val, 4,
+ gdbarch_byte_order (parse_gdbarch), p);
p[len - 2] = 'd';
return DECFLOAT;
}
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type->builtin_decdouble;
- decimal_from_string (putithere->typed_val_decfloat.val, 8, p);
+ decimal_from_string (putithere->typed_val_decfloat.val, 8,
+ gdbarch_byte_order (parse_gdbarch), p);
p[len - 2] = 'd';
return DECFLOAT;
}
p[len - 2] = '\0';
putithere->typed_val_decfloat.type
= parse_type->builtin_declong;
- decimal_from_string (putithere->typed_val_decfloat.val, 16, p);
+ decimal_from_string (putithere->typed_val_decfloat.val, 16,
+ gdbarch_byte_order (parse_gdbarch), p);
p[len - 2] = 'd';
return DECFLOAT;
}
character set name. */
static const char *
-charset_for_string_type (enum c_string_type str_type)
+charset_for_string_type (enum c_string_type str_type,
+ enum bfd_endian byte_order)
{
switch (str_type & ~C_CHAR)
{
case C_STRING:
return target_charset ();
case C_WIDE_STRING:
- return target_wide_charset ();
+ return target_wide_charset (byte_order);
case C_STRING_16:
/* FIXME: UCS-2 is not always correct. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
return "UCS-2BE";
else
return "UCS-2LE";
case C_STRING_32:
/* FIXME: UCS-4 is not always correct. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
return "UCS-4BE";
else
return "UCS-4LE";
/* Classify ELTTYPE according to what kind of character it is. Return
the enum constant representing the character type. Also set
*ENCODING to the name of the character set to use when converting
- characters of this type to the host character set. */
+ characters of this type in target BYTE_ORDER to the host character set. */
static enum c_string_type
-classify_type (struct type *elttype, const char **encoding)
+classify_type (struct type *elttype, enum bfd_endian byte_order,
+ const char **encoding)
{
struct type *saved_type;
enum c_string_type result;
result = C_CHAR;
done:
- *encoding = charset_for_string_type (result);
+ if (encoding)
+ *encoding = charset_for_string_type (result, byte_order);
+
return result;
}
static void
print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
- int width, struct obstack *output, int quoter,
- int *need_escapep)
+ int width, enum bfd_endian byte_order, struct obstack *output,
+ int quoter, int *need_escapep)
{
int need_escape = *need_escapep;
*need_escapep = 0;
for (i = 0; i + width <= orig_len; i += width)
{
char octal[30];
- ULONGEST value = extract_unsigned_integer (&orig[i], width);
+ ULONGEST value;
+ value = extract_unsigned_integer (&orig[i], width, byte_order);
sprintf (octal, "\\%lo", (long) value);
append_string_as_wide (octal, output);
}
static void
c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
struct obstack wchar_buf, output;
struct cleanup *cleanups;
const char *encoding;
struct wchar_iterator *iter;
int need_escape = 0;
- classify_type (type, &encoding);
+ classify_type (type, byte_order, &encoding);
buf = alloca (TYPE_LENGTH (type));
pack_long (buf, type, c);
{
for (i = 0; i < num_chars; ++i)
print_wchar (chars[i], buf, buflen, TYPE_LENGTH (type),
- &wchar_buf, quoter, &need_escape);
+ byte_order, &wchar_buf, quoter, &need_escape);
}
}
/* This handles the NUM_CHARS == 0 case as well. */
if (print_escape)
- print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), &wchar_buf,
- quoter, &need_escape);
+ print_wchar (gdb_WEOF, buf, buflen, TYPE_LENGTH (type), byte_order,
+ &wchar_buf, quoter, &need_escape);
}
/* The output in the host encoding. */
c_printchar (int c, struct type *type, struct ui_file *stream)
{
enum c_string_type str_type;
- const char *encoding;
- str_type = classify_type (type, &encoding);
+ str_type = classify_type (type, BFD_ENDIAN_UNKNOWN, NULL);
switch (str_type)
{
case C_CHAR:
unsigned int length, int force_ellipses,
const struct value_print_options *options)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
style. */
if (!force_ellipses
&& length > 0
- && (extract_unsigned_integer (string + (length - 1) * width, width) == 0))
+ && (extract_unsigned_integer (string + (length - 1) * width,
+ width, byte_order) == 0))
length--;
- str_type = classify_type (type, &encoding) & ~C_CHAR;
+ str_type = classify_type (type, byte_order, &encoding) & ~C_CHAR;
switch (str_type)
{
case C_STRING:
for (i = 0; current_char; ++i)
{
QUIT;
- current_char = extract_unsigned_integer (string + i * width, width);
+ current_char = extract_unsigned_integer (string + i * width,
+ width, byte_order);
}
length = i;
}
obstack_grow_wstr (&wchar_buf, LCST ("'"));
need_escape = 0;
print_wchar (current_char, orig_buf, orig_len, width,
- &wchar_buf, '\'', &need_escape);
+ byte_order, &wchar_buf, '\'', &need_escape);
obstack_grow_wstr (&wchar_buf, LCST ("'"));
{
/* Painful gyrations. */
while (reps-- > 0)
{
print_wchar (current_char, orig_buf, orig_len, width,
- &wchar_buf, '"', &need_escape);
+ byte_order, &wchar_buf, '"', &need_escape);
++things_printed;
}
}
in_quotes = 1;
}
need_escape = 0;
- print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
+ print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
'"', &need_escape);
break;
in_quotes = 0;
}
obstack_grow_wstr (&wchar_buf, LCST (" <incomplete sequence "));
- print_wchar (gdb_WEOF, buf, buflen, width, &wchar_buf,
+ print_wchar (gdb_WEOF, buf, buflen, width, byte_order, &wchar_buf,
0, &need_escape);
obstack_grow_wstr (&wchar_buf, LCST (">"));
finished = 1;
unsigned int fetchlimit;
struct type *type = check_typedef (value_type (value));
struct type *element_type = TYPE_TARGET_TYPE (type);
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
if (element_type == NULL)
goto error;
/* Look for a null character. */
for (i = 0; i < fetchlimit; i++)
- if (extract_unsigned_integer (contents + i * width, width) == 0)
+ if (extract_unsigned_integer (contents + i * width, width,
+ byte_order) == 0)
break;
/* I is now either the number of non-null characters, or FETCHLIMIT. */
else
{
err = read_string (value_as_address (value), -1, width, fetchlimit,
- buffer, length);
+ byte_order, buffer, length);
if (err)
{
xfree (*buffer);
/* If the last character is null, subtract it from LENGTH. */
if (*length > 0
- && extract_unsigned_integer (*buffer + *length - width, width) == 0)
+ && extract_unsigned_integer (*buffer + *length - width, width,
+ byte_order) == 0)
*length -= width;
*charset = target_charset ();
struct value *result;
enum c_string_type dest_type;
const char *dest_charset;
+ enum bfd_endian byte_order;
obstack_init (&output);
cleanup = make_cleanup_obstack_free (&output);
/* Ensure TYPE_LENGTH is valid for TYPE. */
check_typedef (type);
- dest_charset = charset_for_string_type (dest_type);
+ byte_order = gdbarch_byte_order (exp->gdbarch);
+ dest_charset = charset_for_string_type (dest_type, byte_order);
++*pos;
while (*pos < limit)
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int i = 0; /* Number of characters printed */
unsigned len;
struct type *elttype, *unresolved_elttype;
&& temp_len < options->print_max
&& extract_unsigned_integer (valaddr + embedded_offset
+ temp_len * eltlen,
- eltlen) == 0);
+ eltlen, byte_order) == 0);
++temp_len)
;
len = temp_len;
}
const char *
-target_wide_charset (void)
+target_wide_charset (enum bfd_endian byte_order)
{
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
if (target_wide_charset_be_name)
return target_wide_charset_be_name;
it. */
const char *host_charset (void);
const char *target_charset (void);
-const char *target_wide_charset (void);
+const char *target_wide_charset (enum bfd_endian byte_order);
/* These values are used to specify the type of transliteration done
by convert_between_encodings. */
{
CORE_ADDR memaddr;
int len;
+ enum bfd_endian byte_order;
LONGEST result;
};
struct captured_read_memory_integer_arguments *args = (struct captured_read_memory_integer_arguments*) data;
CORE_ADDR memaddr = args->memaddr;
int len = args->len;
+ enum bfd_endian byte_order = args->byte_order;
- args->result = read_memory_integer (memaddr, len);
+ args->result = read_memory_integer (memaddr, len, byte_order);
return 1;
}
if successful. */
int
-safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
+safe_read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order,
+ LONGEST *return_value)
{
int status;
struct captured_read_memory_integer_arguments args;
args.memaddr = memaddr;
args.len = len;
+ args.byte_order = byte_order;
status = catch_errors (do_captured_read_memory_integer, &args,
"", RETURN_MASK_ALL);
}
LONGEST
-read_memory_integer (CORE_ADDR memaddr, int len)
+read_memory_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (LONGEST)];
read_memory (memaddr, buf, len);
- return extract_signed_integer (buf, len);
+ return extract_signed_integer (buf, len, byte_order);
}
ULONGEST
-read_memory_unsigned_integer (CORE_ADDR memaddr, int len)
+read_memory_unsigned_integer (CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (ULONGEST)];
read_memory (memaddr, buf, len);
- return extract_unsigned_integer (buf, len);
+ return extract_unsigned_integer (buf, len, byte_order);
}
void
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
void
-write_memory_unsigned_integer (CORE_ADDR addr, int len, ULONGEST value)
+write_memory_unsigned_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+ ULONGEST value)
{
gdb_byte *buf = alloca (len);
- store_unsigned_integer (buf, len, value);
+ store_unsigned_integer (buf, len, byte_order, value);
write_memory (addr, buf, len);
}
/* Store VALUE at ADDR in the inferior as a LEN-byte signed integer. */
void
-write_memory_signed_integer (CORE_ADDR addr, int len, LONGEST value)
+write_memory_signed_integer (CORE_ADDR addr, int len, enum bfd_endian byte_order,
+ LONGEST value)
{
gdb_byte *buf = alloca (len);
- store_signed_integer (buf, len, value);
+ store_signed_integer (buf, len, byte_order, value);
write_memory (addr, buf, len);
}
\f
cp_print_class_member (const gdb_byte *valaddr, struct type *type,
struct ui_file *stream, char *prefix)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+
/* VAL is a byte offset into the structure type DOMAIN.
Find the name of the field for that offset and
print it. */
struct type *domain = TYPE_DOMAIN_TYPE (type);
- LONGEST val = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+ LONGEST val;
unsigned int fieldno;
+ val = extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
+
/* Pointers to data members are usually byte offsets into an object.
Because a data member can have offset zero, and a NULL pointer to
member must be distinct from any valid non-NULL pointer to
static CORE_ADDR
cris_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc;
CORE_ADDR sp;
char buf[4];
- get_frame_register (this_frame,
- gdbarch_sp_regnum (get_frame_arch (this_frame)), buf);
- sp = extract_unsigned_integer (buf, 4);
+ get_frame_register (this_frame, gdbarch_sp_regnum (gdbarch), buf);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
/* Look for normal sigtramp frame first. */
pc = cris_sigtramp_start (this_frame);
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct cris_unwind_cache *info;
CORE_ADDR pc;
CORE_ADDR sp;
info->leaf_function = 0;
get_frame_register (this_frame, gdbarch_sp_regnum (gdbarch), buf);
- info->base = extract_unsigned_integer (buf, 4);
+ info->base = extract_unsigned_integer (buf, 4, byte_order);
addr = cris_sigcontext_addr (this_frame);
int delay_slot_pc_active;
int xflag_found;
int disable_interrupt;
+ int byte_order;
} inst_env_type;
/* Machine-dependencies in CRIS for opcodes. */
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_alloc;
int stack_offset;
int argreg;
else
{
gdb_byte buf[4];
- store_unsigned_integer (buf, 4, sp);
+ store_unsigned_integer (buf, 4, byte_order, sp);
si = push_stack_item (si, buf, 4);
}
}
struct cris_unwind_cache *info)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* Present instruction. */
unsigned short insn;
/* Find the prologue instructions. */
while (pc > 0 && pc < limit)
{
- insn = read_memory_unsigned_integer (pc, 2);
+ insn = read_memory_unsigned_integer (pc, 2, byte_order);
pc += 2;
if (insn == 0xE1FC)
{
/* push <reg> 32 bit instruction */
- insn_next = read_memory_unsigned_integer (pc, 2);
+ insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
pc += 2;
regno = cris_get_operand2 (insn_next);
if (info)
{
info->sp_offset += -cris_get_signed_offset (insn);
}
- insn_next = read_memory_unsigned_integer (pc, 2);
+ insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
pc += 2;
if (cris_get_mode (insn_next) == PREFIX_ASSIGN_MODE
&& cris_get_opcode (insn_next) == 0x000F
&& (cris_get_signed_offset (insn) < 0))
{
/* move.S rZ,[r8-U] (?) */
- insn_next = read_memory_unsigned_integer (pc, 2);
+ insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
pc += 2;
regno = cris_get_operand2 (insn_next);
if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
&& (cris_get_signed_offset (insn) > 0))
{
/* move.S [r8+U],rZ (?) */
- insn_next = read_memory_unsigned_integer (pc, 2);
+ insn_next = read_memory_unsigned_integer (pc, 2, byte_order);
pc += 2;
regno = cris_get_operand2 (insn_next);
if ((regno >= 0 && regno < gdbarch_sp_regnum (gdbarch))
cris_store_return_value (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
int len = TYPE_LENGTH (type);
if (len <= 4)
{
/* Put the return value in R10. */
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
}
else if (len <= 8)
{
/* Put the return value in R10 and R11. */
- val = extract_unsigned_integer (valbuf, 4);
+ val = extract_unsigned_integer (valbuf, 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG1_REGNUM, val);
- val = extract_unsigned_integer ((char *)valbuf + 4, len - 4);
+ val = extract_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order);
regcache_cooked_write_unsigned (regcache, ARG2_REGNUM, val);
}
else
cris_extract_return_value (struct type *type, struct regcache *regcache,
void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
int len = TYPE_LENGTH (type);
{
/* Get the return value from R10. */
regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
- store_unsigned_integer (valbuf, len, val);
+ store_unsigned_integer (valbuf, len, byte_order, val);
}
else if (len <= 8)
{
/* Get the return value from R10 and R11. */
regcache_cooked_read_unsigned (regcache, ARG1_REGNUM, &val);
- store_unsigned_integer (valbuf, 4, val);
+ store_unsigned_integer (valbuf, 4, byte_order, val);
regcache_cooked_read_unsigned (regcache, ARG2_REGNUM, &val);
- store_unsigned_integer ((char *)valbuf + 4, len - 4, val);
+ store_unsigned_integer ((char *)valbuf + 4, len - 4, byte_order, val);
}
else
error (_("cris_extract_return_value: type length too large"));
int offset;
unsigned short insn;
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Create a local register image and set the initial state. */
for (i = 0; i < NUM_GENREGS; i++)
inst_env->invalid = 0;
inst_env->xflag_found = 0;
inst_env->disable_interrupt = 0;
+ inst_env->byte_order = byte_order;
/* Look for a step target. */
do
{
/* Read an instruction from the client. */
insn = read_memory_unsigned_integer
- (inst_env->reg[gdbarch_pc_regnum (gdbarch)], 2);
+ (inst_env->reg[gdbarch_pc_regnum (gdbarch)], 2, byte_order);
/* If the instruction is not in a delay slot the new content of the
PC is [PC] + 2. If the instruction is in a delay slot it is not
/* Just a forward declaration. */
static unsigned long get_data_from_address (unsigned short *inst,
- CORE_ADDR address);
+ CORE_ADDR address,
+ enum bfd_endian byte_order);
/* Calculates the prefix value for the general case of offset addressing
mode. */
/* The offset is an indirection of the contents of the operand1 register. */
inst_env->prefix_value +=
- get_data_from_address (&inst, inst_env->reg[cris_get_operand1 (inst)]);
+ get_data_from_address (&inst, inst_env->reg[cris_get_operand1 (inst)],
+ inst_env->byte_order);
if (cris_get_mode (inst) == AUTOINC_MODE)
{
/* The prefix value is one dereference of the contents of the operand1
register. */
address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
- inst_env->prefix_value = read_memory_unsigned_integer (address, 4);
+ inst_env->prefix_value
+ = read_memory_unsigned_integer (address, 4, inst_env->byte_order);
/* Check if the mode is autoincrement. */
if (cris_get_mode (inst) == AUTOINC_MODE)
}
/* We have a branch, find out the offset for the branch. */
- offset = read_memory_integer (inst_env->reg[REG_PC], 2);
+ offset = read_memory_integer (inst_env->reg[REG_PC], 2, inst_env->byte_order);
/* The instruction is one word longer than normal, so add one word
to the PC. */
/* Get the new value for the the PC. */
newpc =
read_memory_unsigned_integer ((CORE_ADDR) inst_env->prefix_value,
- 4);
+ 4, inst_env->byte_order);
}
else
{
/* Get the new value for the PC. */
address = (CORE_ADDR) inst_env->reg[cris_get_operand1 (inst)];
- newpc = read_memory_unsigned_integer (address, 4);
+ newpc = read_memory_unsigned_integer (address,
+ 4, inst_env->byte_order);
/* Check if we should increment a register. */
if (cris_get_mode (inst) == AUTOINC_MODE)
if (cris_get_operand2 (inst) >= REG_PC)
{
inst_env->reg[REG_PC] =
- read_memory_unsigned_integer (inst_env->prefix_value, 4);
+ read_memory_unsigned_integer (inst_env->prefix_value,
+ 4, inst_env->byte_order);
}
/* The assign value is the value after the increment. Normally, the
assign value is the value before the increment. */
}
inst_env->reg[REG_PC] =
read_memory_unsigned_integer (inst_env->reg[cris_get_operand1 (inst)],
- 4);
+ 4, inst_env->byte_order);
}
/* The increment is not depending on the size, instead it's depending
on the number of registers loaded from memory. */
extend instruction, the size field is changed in instruction. */
static unsigned long
-get_data_from_address (unsigned short *inst, CORE_ADDR address)
+get_data_from_address (unsigned short *inst, CORE_ADDR address, enum bfd_endian byte_order)
{
int size = cris_get_size (*inst);
unsigned long value;
/* Is there a need for checking the size? Size should contain the number of
bytes to read. */
size = 1 << size;
- value = read_memory_unsigned_integer (address, size);
+ value = read_memory_unsigned_integer (address, size, byte_order);
/* Check if it's an extend, signed or zero instruction. */
if (cris_get_opcode (*inst) < 4)
operand2 = inst_env->reg[REG_PC];
/* Get the value of the third operand. */
- operand3 = get_data_from_address (&inst, inst_env->prefix_value);
+ operand3 = get_data_from_address (&inst, inst_env->prefix_value,
+ inst_env->byte_order);
/* Calculate the PC value after the instruction, i.e. where the
breakpoint should be. The order of the udw_operands is vital. */
operand2 = inst_env->reg[cris_get_operand2 (inst)];
/* Get the value of the third operand. */
- operand3 = get_data_from_address (&inst, inst_env->prefix_value);
+ operand3 = get_data_from_address (&inst, inst_env->prefix_value,
+ inst_env->byte_order);
/* Calculate the PC value after the instruction, i.e. where the
breakpoint should be. */
/* Get the value of the third operand, i.e. the indirect operand. */
operand1 = inst_env->reg[cris_get_operand1 (inst)];
- operand3 = get_data_from_address (&inst, operand1);
+ operand3 = get_data_from_address (&inst, operand1, inst_env->byte_order);
/* Calculate the PC value after the instruction, i.e. where the
breakpoint should be. The order of the udw_operands is vital. */
/* In findvar.c. */
-extern LONGEST extract_signed_integer (const gdb_byte *, int);
+extern LONGEST extract_signed_integer (const gdb_byte *, int,
+ enum bfd_endian);
-extern ULONGEST extract_unsigned_integer (const gdb_byte *, int);
+extern ULONGEST extract_unsigned_integer (const gdb_byte *, int,
+ enum bfd_endian);
-extern int extract_long_unsigned_integer (const gdb_byte *, int, LONGEST *);
+extern int extract_long_unsigned_integer (const gdb_byte *, int,
+ enum bfd_endian, LONGEST *);
extern CORE_ADDR extract_typed_address (const gdb_byte *buf,
struct type *type);
-extern void store_signed_integer (gdb_byte *, int, LONGEST);
+extern void store_signed_integer (gdb_byte *, int,
+ enum bfd_endian, LONGEST);
-extern void store_unsigned_integer (gdb_byte *, int, ULONGEST);
+extern void store_unsigned_integer (gdb_byte *, int,
+ enum bfd_endian, ULONGEST);
extern void store_typed_address (gdb_byte *buf, struct type *type,
CORE_ADDR addr);
They are stored in host byte order. This routine does the conversion if
the target byte order is different. */
static void
-match_endianness (const gdb_byte *from, int len, gdb_byte *to)
+match_endianness (const gdb_byte *from, int len, enum bfd_endian byte_order,
+ gdb_byte *to)
{
int i;
#define OPPOSITE_BYTE_ORDER BFD_ENDIAN_BIG
#endif
- if (gdbarch_byte_order (current_gdbarch) == OPPOSITE_BYTE_ORDER)
+ if (byte_order == OPPOSITE_BYTE_ORDER)
for (i = 0; i < len; i++)
to[i] = from[len - i - 1];
else
of the decimal type, 4 bytes for decimal32, 8 bytes for decimal64 and
16 bytes for decimal128. */
void
-decimal_to_string (const gdb_byte *decbytes, int len, char *s)
+decimal_to_string (const gdb_byte *decbytes, int len,
+ enum bfd_endian byte_order, char *s)
{
gdb_byte dec[16];
- match_endianness (decbytes, len, dec);
+ match_endianness (decbytes, len, byte_order, dec);
switch (len)
{
LEN is the length of the decimal type, 4 bytes for decimal32, 8 bytes for
decimal64 and 16 bytes for decimal128. */
int
-decimal_from_string (gdb_byte *decbytes, int len, const char *string)
+decimal_from_string (gdb_byte *decbytes, int len, enum bfd_endian byte_order,
+ const char *string)
{
decContext set;
gdb_byte dec[16];
break;
}
- match_endianness (dec, len, decbytes);
+ match_endianness (dec, len, byte_order, decbytes);
/* Check for errors in the DFP operation. */
decimal_check_errors (&set);
/* Converts a value of an integral type to a decimal float of
specified LEN bytes. */
void
-decimal_from_integral (struct value *from, gdb_byte *to, int len)
+decimal_from_integral (struct value *from,
+ gdb_byte *to, int len, enum bfd_endian byte_order)
{
LONGEST l;
gdb_byte dec[16];
decNumberFromInt32 (&number, (int) l);
decimal_from_number (&number, dec, len);
- match_endianness (dec, len, to);
+ match_endianness (dec, len, byte_order, to);
}
/* Converts a value of a float type to a decimal float of
This is an ugly way to do the conversion, but libdecnumber does
not offer a direct way to do it. */
void
-decimal_from_floating (struct value *from, gdb_byte *to, int len)
+decimal_from_floating (struct value *from,
+ gdb_byte *to, int len, enum bfd_endian byte_order)
{
char *buffer;
buffer = xstrprintf ("%.30" DOUBLEST_PRINT_FORMAT, value_as_double (from));
- decimal_from_string (to, len, buffer);
+ decimal_from_string (to, len, byte_order, buffer);
xfree (buffer);
}
/* Converts a decimal float of LEN bytes to a double value. */
DOUBLEST
-decimal_to_doublest (const gdb_byte *from, int len)
+decimal_to_doublest (const gdb_byte *from, int len, enum bfd_endian byte_order)
{
char buffer[MAX_DECIMAL_STRING];
/* This is an ugly way to do the conversion, but libdecnumber does
not offer a direct way to do it. */
- decimal_to_string (from, len, buffer);
+ decimal_to_string (from, len, byte_order, buffer);
return strtod (buffer, NULL);
}
/* Perform operation OP with operands X and Y with sizes LEN_X and LEN_Y
- and store value in RESULT with size LEN_RESULT. */
+ and byte orders BYTE_ORDER_X and BYTE_ORDER_Y, and store value in
+ RESULT with size LEN_RESULT and byte order BYTE_ORDER_RESULT. */
void
-decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
- const gdb_byte *y, int len_y, gdb_byte *result, int len_result)
+decimal_binop (enum exp_opcode op,
+ const gdb_byte *x, int len_x, enum bfd_endian byte_order_x,
+ const gdb_byte *y, int len_y, enum bfd_endian byte_order_y,
+ gdb_byte *result, int len_result,
+ enum bfd_endian byte_order_result)
{
decContext set;
decNumber number1, number2, number3;
gdb_byte dec1[16], dec2[16], dec3[16];
- match_endianness (x, len_x, dec1);
- match_endianness (y, len_y, dec2);
+ match_endianness (x, len_x, byte_order_x, dec1);
+ match_endianness (y, len_y, byte_order_y, dec2);
decimal_to_number (dec1, len_x, &number1);
decimal_to_number (dec2, len_y, &number2);
decimal_from_number (&number3, dec3, len_result);
- match_endianness (dec3, len_result, result);
+ match_endianness (dec3, len_result, byte_order_result, result);
}
/* Returns true if X (which is LEN bytes wide) is the number zero. */
int
-decimal_is_zero (const gdb_byte *x, int len)
+decimal_is_zero (const gdb_byte *x, int len, enum bfd_endian byte_order)
{
decNumber number;
gdb_byte dec[16];
- match_endianness (x, len, dec);
+ match_endianness (x, len, byte_order, dec);
decimal_to_number (dec, len, &number);
return decNumberIsZero (&number);
will be -1. If they are equal, then the return value will be 0. If X is
greater than the Y then the return value will be 1. */
int
-decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y)
+decimal_compare (const gdb_byte *x, int len_x, enum bfd_endian byte_order_x,
+ const gdb_byte *y, int len_y, enum bfd_endian byte_order_y)
{
decNumber number1, number2, result;
decContext set;
gdb_byte dec1[16], dec2[16];
int len_result;
- match_endianness (x, len_x, dec1);
- match_endianness (y, len_y, dec2);
+ match_endianness (x, len_x, byte_order_x, dec1);
+ match_endianness (y, len_y, byte_order_y, dec2);
decimal_to_number (dec1, len_x, &number1);
decimal_to_number (dec2, len_y, &number2);
/* Convert a decimal value from a decimal type with LEN_FROM bytes to a
decimal type with LEN_TO bytes. */
void
-decimal_convert (const gdb_byte *from, int len_from, gdb_byte *to,
- int len_to)
+decimal_convert (const gdb_byte *from, int len_from,
+ enum bfd_endian byte_order_from, gdb_byte *to, int len_to,
+ enum bfd_endian byte_order_to)
{
decNumber number;
gdb_byte dec[16];
- match_endianness (from, len_from, dec);
+ match_endianness (from, len_from, byte_order_from, dec);
decimal_to_number (dec, len_from, &number);
decimal_from_number (&number, dec, len_to);
- match_endianness (dec, len_to, to);
+ match_endianness (dec, len_to, byte_order_to, to);
}
* (value comes from libdecnumber's DECIMAL128_String constant). */
#define MAX_DECIMAL_STRING 43
-extern void decimal_to_string (const gdb_byte *, int, char *);
-extern int decimal_from_string (gdb_byte *, int, const char *);
-extern void decimal_from_integral (struct value *from, gdb_byte *to, int len);
-extern void decimal_from_floating (struct value *from, gdb_byte *to, int len);
-extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len);
-extern void decimal_binop (enum exp_opcode, const gdb_byte *, int,
- const gdb_byte *, int, gdb_byte *, int);
-extern int decimal_is_zero (const gdb_byte *x, int len);
-extern int decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y);
-extern void decimal_convert (const gdb_byte *from, int len_from, gdb_byte *to,
- int len_to);
+extern void decimal_to_string (const gdb_byte *, int, enum bfd_endian, char *);
+extern int decimal_from_string (gdb_byte *, int, enum bfd_endian, const char *);
+extern void decimal_from_integral (struct value *from, gdb_byte *to,
+ int len, enum bfd_endian byte_order);
+extern void decimal_from_floating (struct value *from, gdb_byte *to,
+ int len, enum bfd_endian byte_order);
+extern DOUBLEST decimal_to_doublest (const gdb_byte *from, int len,
+ enum bfd_endian byte_order);
+extern void decimal_binop (enum exp_opcode,
+ const gdb_byte *, int, enum bfd_endian,
+ const gdb_byte *, int, enum bfd_endian,
+ gdb_byte *, int, enum bfd_endian);
+extern int decimal_is_zero (const gdb_byte *, int, enum bfd_endian);
+extern int decimal_compare (const gdb_byte *, int, enum bfd_endian,
+ const gdb_byte *, int, enum bfd_endian);
+extern void decimal_convert (const gdb_byte *, int, enum bfd_endian,
+ gdb_byte *, int, enum bfd_endian);
#endif
CORE_ADDR pc = get_frame_pc (this_frame);
int bytes_read;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
while (insn_ptr < insn_end && fs->pc <= pc)
{
break;
case DW_CFA_advance_loc1:
- utmp = extract_unsigned_integer (insn_ptr, 1);
+ utmp = extract_unsigned_integer (insn_ptr, 1, byte_order);
fs->pc += utmp * fs->code_align;
insn_ptr++;
break;
case DW_CFA_advance_loc2:
- utmp = extract_unsigned_integer (insn_ptr, 2);
+ utmp = extract_unsigned_integer (insn_ptr, 2, byte_order);
fs->pc += utmp * fs->code_align;
insn_ptr += 2;
break;
case DW_CFA_advance_loc4:
- utmp = extract_unsigned_integer (insn_ptr, 4);
+ utmp = extract_unsigned_integer (insn_ptr, 4, byte_order);
fs->pc += utmp * fs->code_align;
insn_ptr += 4;
break;
dwarf2_read_address (struct gdbarch *gdbarch, gdb_byte *buf,
gdb_byte *buf_end, int addr_size)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR result;
if (buf_end - buf < addr_size)
return gdbarch_integer_to_address
(gdbarch, unsigned_address_type (gdbarch, addr_size), buf);
- return extract_unsigned_integer (buf, addr_size);
+ return extract_unsigned_integer (buf, addr_size, byte_order);
}
/* Return the type of an address of size ADDR_SIZE,
execute_stack_op (struct dwarf_expr_context *ctx,
gdb_byte *op_ptr, gdb_byte *op_end)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (ctx->gdbarch);
+
ctx->in_reg = 0;
ctx->initialized = 1; /* Default is initialized. */
break;
case DW_OP_const1u:
- result = extract_unsigned_integer (op_ptr, 1);
+ result = extract_unsigned_integer (op_ptr, 1, byte_order);
op_ptr += 1;
break;
case DW_OP_const1s:
- result = extract_signed_integer (op_ptr, 1);
+ result = extract_signed_integer (op_ptr, 1, byte_order);
op_ptr += 1;
break;
case DW_OP_const2u:
- result = extract_unsigned_integer (op_ptr, 2);
+ result = extract_unsigned_integer (op_ptr, 2, byte_order);
op_ptr += 2;
break;
case DW_OP_const2s:
- result = extract_signed_integer (op_ptr, 2);
+ result = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
break;
case DW_OP_const4u:
- result = extract_unsigned_integer (op_ptr, 4);
+ result = extract_unsigned_integer (op_ptr, 4, byte_order);
op_ptr += 4;
break;
case DW_OP_const4s:
- result = extract_signed_integer (op_ptr, 4);
+ result = extract_signed_integer (op_ptr, 4, byte_order);
op_ptr += 4;
break;
case DW_OP_const8u:
- result = extract_unsigned_integer (op_ptr, 8);
+ result = extract_unsigned_integer (op_ptr, 8, byte_order);
op_ptr += 8;
break;
case DW_OP_const8s:
- result = extract_signed_integer (op_ptr, 8);
+ result = extract_signed_integer (op_ptr, 8, byte_order);
op_ptr += 8;
break;
case DW_OP_constu:
break;
case DW_OP_skip:
- offset = extract_signed_integer (op_ptr, 2);
+ offset = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
op_ptr += offset;
goto no_push;
case DW_OP_bra:
- offset = extract_signed_integer (op_ptr, 2);
+ offset = extract_signed_integer (op_ptr, 2, byte_order);
op_ptr += 2;
if (dwarf_expr_fetch (ctx, 0) != 0)
op_ptr += offset;
int length;
struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = dwarf2_per_cu_addr_size (baton->per_cu);
CORE_ADDR base_mask = ~(~(CORE_ADDR)1 << (addr_size * 8 - 1));
/* Adjust base_address for relocatable objects. */
low += base_address;
high += base_address;
- length = extract_unsigned_integer (loc_ptr, 2);
+ length = extract_unsigned_integer (loc_ptr, 2, byte_order);
loc_ptr += 2;
if (pc >= low && pc < high)
{
struct objfile *objfile = cu->objfile;
struct comp_unit_head *cu_header = &cu->header;
+ enum bfd_endian byte_order = bfd_big_endian (objfile->obfd) ?
+ BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
struct dwarf_block *blk;
switch (attr->form)
/* NOTE: cagney/2003-05-09: In-lined store_address call with
it's body - store_unsigned_integer. */
store_unsigned_integer (SYMBOL_VALUE_BYTES (sym), cu_header->addr_size,
- DW_ADDR (attr));
+ DW_ADDR (attr), byte_order);
SYMBOL_CLASS (sym) = LOC_CONST_BYTES;
break;
case DW_FORM_string:
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int i = 0; /* Number of characters printed */
struct type *elttype;
LONGEST val;
}
else
{
- val = extract_unsigned_integer (valaddr, TYPE_LENGTH (type));
-
+ val = extract_unsigned_integer (valaddr,
+ TYPE_LENGTH (type), byte_order);
if (val == 0)
fprintf_filtered (stream, ".FALSE.");
else if (val == 1)
#endif
LONGEST
-extract_signed_integer (const gdb_byte *addr, int len)
+extract_signed_integer (const gdb_byte *addr, int len,
+ enum bfd_endian byte_order)
{
LONGEST retval;
const unsigned char *p;
/* Start at the most significant end of the integer, and work towards
the least significant. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
p = startaddr;
/* Do the sign extension once at the start. */
}
ULONGEST
-extract_unsigned_integer (const gdb_byte *addr, int len)
+extract_unsigned_integer (const gdb_byte *addr, int len,
+ enum bfd_endian byte_order)
{
ULONGEST retval;
const unsigned char *p;
/* Start at the most significant end of the integer, and work towards
the least significant. */
retval = 0;
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
for (p = startaddr; p < endaddr; ++p)
retval = (retval << 8) | *p;
int
extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
- LONGEST *pval)
+ enum bfd_endian byte_order, LONGEST *pval)
{
const gdb_byte *p;
const gdb_byte *first_addr;
int len;
len = orig_len;
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
for (p = addr;
len > (int) sizeof (LONGEST) && p < addr + orig_len;
if (len <= (int) sizeof (LONGEST))
{
*pval = (LONGEST) extract_unsigned_integer (first_addr,
- sizeof (LONGEST));
+ sizeof (LONGEST),
+ byte_order);
return 1;
}
void
-store_signed_integer (gdb_byte *addr, int len, LONGEST val)
+store_signed_integer (gdb_byte *addr, int len,
+ enum bfd_endian byte_order, LONGEST val)
{
gdb_byte *p;
gdb_byte *startaddr = addr;
/* Start at the least significant end of the integer, and work towards
the most significant. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
for (p = endaddr - 1; p >= startaddr; --p)
{
}
void
-store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val)
+store_unsigned_integer (gdb_byte *addr, int len,
+ enum bfd_endian byte_order, ULONGEST val)
{
unsigned char *p;
unsigned char *startaddr = (unsigned char *) addr;
/* Start at the least significant end of the integer, and work towards
the most significant. */
- if (gdbarch_byte_order (current_gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
for (p = endaddr - 1; p >= startaddr; --p)
{
unsigned_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
- return extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
}
CORE_ADDR
signed_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
- return extract_signed_integer (buf, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order);
}
/* Given an address, store it as a pointer of type TYPE in target
unsigned_address_to_pointer (struct gdbarch *gdbarch, struct type *type,
gdb_byte *buf, CORE_ADDR addr)
{
- store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
void
address_to_signed_pointer (struct gdbarch *gdbarch, struct type *type,
gdb_byte *buf, CORE_ADDR addr)
{
- store_signed_integer (buf, TYPE_LENGTH (type), addr);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ store_signed_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
\f
/* Will calling read_var_value or locate_var_value on SYM end
case LOC_CONST:
/* Put the constant back in target format. */
store_signed_integer (value_contents_raw (v), len,
+ gdbarch_byte_order (get_type_arch (type)),
(LONGEST) SYMBOL_VALUE (var));
VALUE_LVAL (v) = not_lval;
return v;
ULONGEST val)
{
struct gdbarch *gdbarch = frame_unwind_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct value *reg_val;
reg_val = value_zero (register_type (gdbarch, regnum), not_lval);
store_unsigned_integer (value_contents_writeable (reg_val),
- register_size (gdbarch, regnum), val);
+ register_size (gdbarch, regnum), byte_order, val);
return reg_val;
}
LONGEST
frame_unwind_register_signed (struct frame_info *frame, int regnum)
{
+ struct gdbarch *gdbarch = frame_unwind_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int size = register_size (gdbarch, regnum);
gdb_byte buf[MAX_REGISTER_SIZE];
frame_unwind_register (frame, regnum, buf);
- return extract_signed_integer (buf, register_size (frame_unwind_arch (frame),
- regnum));
+ return extract_signed_integer (buf, size, byte_order);
}
LONGEST
ULONGEST
frame_unwind_register_unsigned (struct frame_info *frame, int regnum)
{
+ struct gdbarch *gdbarch = frame_unwind_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int size = register_size (gdbarch, regnum);
gdb_byte buf[MAX_REGISTER_SIZE];
frame_unwind_register (frame, regnum, buf);
- return extract_unsigned_integer (buf, register_size (frame_unwind_arch (frame),
- regnum));
+ return extract_unsigned_integer (buf, size, byte_order);
}
ULONGEST
get_frame_memory_signed (struct frame_info *this_frame, CORE_ADDR addr,
int len)
{
- return read_memory_integer (addr, len);
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return read_memory_integer (addr, len, byte_order);
}
ULONGEST
get_frame_memory_unsigned (struct frame_info *this_frame, CORE_ADDR addr,
int len)
{
- return read_memory_unsigned_integer (addr, len);
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return read_memory_unsigned_integer (addr, len, byte_order);
}
int
};
static int
-frv_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
+frv_linux_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc, char *name)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[frv_instr_size];
LONGEST instr;
int retval = 0;
if (target_read_memory (pc, buf, sizeof buf) != 0)
return 0;
- instr = extract_unsigned_integer (buf, sizeof buf);
+ instr = extract_unsigned_integer (buf, sizeof buf, byte_order);
if (instr == 0x8efc0077) /* setlos #__NR_sigreturn, gr7 */
retval = NORMAL_SIGTRAMP;
if (target_read_memory (pc + frv_instr_size, buf, sizeof buf) != 0)
return 0;
- instr = extract_unsigned_integer (buf, sizeof buf);
+ instr = extract_unsigned_integer (buf, sizeof buf, byte_order);
if (instr != 0xc0700000) /* tira gr0, 0 */
return 0;
frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
CORE_ADDR *sc_addr_cache_ptr)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sc_addr;
if (sc_addr_cache_ptr && *sc_addr_cache_ptr)
int tramp_type;
pc = get_frame_pc (this_frame);
- tramp_type = frv_linux_pc_in_sigtramp (pc, 0);
+ tramp_type = frv_linux_pc_in_sigtramp (gdbarch, pc, 0);
get_frame_register (this_frame, sp_regnum, buf);
- sp = extract_unsigned_integer (buf, sizeof buf);
+ sp = extract_unsigned_integer (buf, sizeof buf, byte_order);
if (tramp_type == NORMAL_SIGTRAMP)
{
warning (_("Can't read realtime sigtramp frame."));
return 0;
}
- sc_addr = extract_unsigned_integer (buf, sizeof buf);
+ sc_addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
sc_addr += 24;
}
else
static struct trad_frame_cache *
frv_linux_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct trad_frame_cache *cache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
CORE_ADDR addr;
char buf[4];
int regnum;
signal trampoline and not the current PC within that
trampoline. */
get_frame_register (this_frame, sp_regnum, buf);
- this_id = frame_id_build (extract_unsigned_integer (buf, sizeof buf),
- get_frame_pc (this_frame));
+ addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
+ this_id = frame_id_build (addr, get_frame_pc (this_frame));
trad_frame_set_id (cache, this_id);
for (regnum = 0; regnum < frv_num_regs; regnum++)
struct frame_info *this_frame,
void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
CORE_ADDR pc = get_frame_pc (this_frame);
char *name;
find_pc_partial_function (pc, &name, NULL, NULL);
- if (frv_linux_pc_in_sigtramp (pc, name))
+ if (frv_linux_pc_in_sigtramp (gdbarch, pc, name))
return 1;
return 0;
struct frame_info *this_frame,
struct frv_unwind_cache *info)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* When writing out instruction bitpatterns, we use the following
letters to label instruction fields:
P - The parallel bit. We don't use this.
if (target_read_memory (pc, buf, sizeof buf) != 0)
break;
- op = extract_signed_integer (buf, sizeof buf);
+ op = extract_signed_integer (buf, sizeof buf, byte_order);
next_pc = pc + 4;
static CORE_ADDR
frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
unsigned long op;
CORE_ADDR orig_pc = pc;
if (target_read_memory (pc, buf, 4))
return pc;
- op = extract_unsigned_integer (buf, 4);
+ op = extract_unsigned_integer (buf, 4, byte_order);
/* In PIC code, GR15 may be loaded from some offset off of FP prior
to the call instruction.
pc += 4;
if (target_read_memory (pc, buf, 4))
return orig_pc;
- op = extract_unsigned_integer (buf, 4);
+ op = extract_unsigned_integer (buf, 4, byte_order);
}
/* The format of an FRV CALL instruction is as follows:
frv_extract_return_value (struct type *type, struct regcache *regcache,
gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
if (len <= 4)
{
ULONGEST gpr8_val;
regcache_cooked_read_unsigned (regcache, 8, &gpr8_val);
- store_unsigned_integer (valbuf, len, gpr8_val);
+ store_unsigned_integer (valbuf, len, byte_order, gpr8_val);
}
else if (len == 8)
{
ULONGEST regval;
regcache_cooked_read_unsigned (regcache, 8, ®val);
- store_unsigned_integer (valbuf, 4, regval);
+ store_unsigned_integer (valbuf, 4, byte_order, regval);
regcache_cooked_read_unsigned (regcache, 9, ®val);
- store_unsigned_integer ((bfd_byte *) valbuf + 4, 4, regval);
+ store_unsigned_integer ((bfd_byte *) valbuf + 4, 4, byte_order, regval);
}
else
internal_error (__FILE__, __LINE__, _("Illegal return value length: %d"), len);
static CORE_ADDR
find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR descr;
char valbuf[4];
CORE_ADDR start_addr;
the stack. */
descr = value_as_long (value_allocate_space_in_inferior (8));
- store_unsigned_integer (valbuf, 4, entry_point);
+ store_unsigned_integer (valbuf, 4, byte_order, entry_point);
write_memory (descr, valbuf, 4);
- store_unsigned_integer (valbuf, 4,
+ store_unsigned_integer (valbuf, 4, byte_order,
frv_fdpic_find_global_pointer (entry_point));
write_memory (descr + 4, valbuf, 4);
return descr;
frv_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR entry_point;
CORE_ADDR got_address;
- entry_point = get_target_memory_unsigned (targ, addr, 4);
- got_address = get_target_memory_unsigned (targ, addr + 4, 4);
+ entry_point = get_target_memory_unsigned (targ, addr, 4, byte_order);
+ got_address = get_target_memory_unsigned (targ, addr + 4, 4, byte_order);
if (got_address == frv_fdpic_find_global_pointer (entry_point))
return entry_point;
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argreg;
int argnum;
char *val;
if (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION)
{
- store_unsigned_integer (valbuf, 4, value_address (arg));
+ store_unsigned_integer (valbuf, 4, byte_order,
+ value_address (arg));
typecode = TYPE_CODE_PTR;
len = 4;
val = valbuf;
{
/* The FDPIC ABI requires function descriptors to be passed instead
of entry points. */
- store_unsigned_integer
- (valbuf, 4,
- find_func_descr (gdbarch,
- extract_unsigned_integer (value_contents (arg),
- 4)));
+ CORE_ADDR addr = extract_unsigned_integer
+ (value_contents (arg), 4, byte_order);
+ addr = find_func_descr (gdbarch, addr);
+ store_unsigned_integer (valbuf, 4, byte_order, addr);
typecode = TYPE_CODE_PTR;
len = 4;
val = valbuf;
if (argreg < 14)
{
- regval = extract_unsigned_integer (val, partial_len);
+ regval = extract_unsigned_integer (val, partial_len, byte_order);
#if 0
printf(" Argnum %d data %x -> reg %d\n",
argnum, (int) regval, argreg);
0, /* print_insn */
0, /* skip_trampoline_code */
generic_skip_solib_resolver, /* skip_solib_resolver */
- 0, /* in_solib_return_trampoline */
+ generic_in_solib_return_trampoline, /* in_solib_return_trampoline */
generic_in_function_epilogue_p, /* in_function_epilogue_p */
0, /* elf_make_msymbol_special */
0, /* coff_make_msymbol_special */
gdb_assert (gdbarch->in_solib_return_trampoline != NULL);
if (gdbarch_debug >= 2)
fprintf_unfiltered (gdb_stdlog, "gdbarch_in_solib_return_trampoline called\n");
- return gdbarch->in_solib_return_trampoline (pc, name);
+ return gdbarch->in_solib_return_trampoline (gdbarch, pc, name);
}
void
/* Some systems also have trampoline code for returning from shared libs. */
-typedef int (gdbarch_in_solib_return_trampoline_ftype) (CORE_ADDR pc, char *name);
+typedef int (gdbarch_in_solib_return_trampoline_ftype) (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
extern int gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char *name);
extern void set_gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, gdbarch_in_solib_return_trampoline_ftype *in_solib_return_trampoline);
# a step-resume breakpoint to get us past the dynamic linker.
m:CORE_ADDR:skip_solib_resolver:CORE_ADDR pc:pc::generic_skip_solib_resolver::0
# Some systems also have trampoline code for returning from shared libs.
-f:int:in_solib_return_trampoline:CORE_ADDR pc, char *name:pc, name::generic_in_solib_return_trampoline::0
+m:int:in_solib_return_trampoline:CORE_ADDR pc, char *name:pc, name::generic_in_solib_return_trampoline::0
# A target might have problems with watchpoints as soon as the stack
# frame of the current function has been destroyed. This mostly happens
/* Read an integer from debugged memory, given address and number of
bytes. */
-extern LONGEST read_memory_integer (CORE_ADDR memaddr, int len);
-extern int safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value);
+extern LONGEST read_memory_integer (CORE_ADDR memaddr,
+ int len, enum bfd_endian byte_order);
+extern int safe_read_memory_integer (CORE_ADDR memaddr, int len,
+ enum bfd_endian byte_order, LONGEST *return_value);
/* Read an unsigned integer from debugged memory, given address and
number of bytes. */
-extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr, int len);
+extern ULONGEST read_memory_unsigned_integer (CORE_ADDR memaddr,
+ int len, enum bfd_endian byte_order);
/* Read a null-terminated string from the debuggee's memory, given address,
* a buffer into which to place the string, and the maximum available space */
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
extern void write_memory_unsigned_integer (CORE_ADDR addr, int len,
- ULONGEST value);
+ enum bfd_endian byte_order,
+ ULONGEST value);
/* Store VALUE at ADDR in the inferior as a LEN-byte unsigned integer. */
extern void write_memory_signed_integer (CORE_ADDR addr, int len,
+ enum bfd_endian byte_order,
LONGEST value);
\f
/* Hook for `exec_file_command' command to call. */
{
struct type *funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
struct type *offset_type = vtable_ptrdiff_type (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR ptr_value;
LONGEST voffset, adjustment;
int vbit;
yet know which case we have, so we extract the value under both
interpretations and choose the right one later on. */
ptr_value = extract_typed_address (contents, funcptr_type);
- voffset = extract_signed_integer (contents, TYPE_LENGTH (funcptr_type));
+ voffset = extract_signed_integer (contents,
+ TYPE_LENGTH (funcptr_type), byte_order);
contents += TYPE_LENGTH (funcptr_type);
- adjustment = extract_signed_integer (contents, TYPE_LENGTH (offset_type));
+ adjustment = extract_signed_integer (contents,
+ TYPE_LENGTH (offset_type), byte_order);
if (!gdbarch_vbit_in_delta (gdbarch))
{
struct type *domain_type = check_typedef (TYPE_DOMAIN_TYPE (type));
struct gdbarch *gdbarch = get_type_arch (domain_type);
int size = TYPE_LENGTH (builtin_type (gdbarch)->builtin_data_ptr);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* FIXME drow/2006-12-24: The adjustment of "this" is currently
always zero, since the method pointer is of the correct type.
if (!gdbarch_vbit_in_delta (gdbarch))
{
- store_unsigned_integer (contents, size, value | is_virtual);
- store_unsigned_integer (contents + size, size, 0);
+ store_unsigned_integer (contents, size, byte_order, value | is_virtual);
+ store_unsigned_integer (contents + size, size, byte_order, 0);
}
else
{
- store_unsigned_integer (contents, size, value);
- store_unsigned_integer (contents + size, size, is_virtual);
+ store_unsigned_integer (contents, size, byte_order, value);
+ store_unsigned_integer (contents + size, size, byte_order, is_virtual);
}
}
is used, it could be a byte, word or long move to registers r3-r5. */
static int
-h8300_is_argument_spill (CORE_ADDR pc)
+h8300_is_argument_spill (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- int w = read_memory_unsigned_integer (pc, 2);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int w = read_memory_unsigned_integer (pc, 2, byte_order);
if ((IS_MOVB_RnRm (w) || IS_MOVW_RnRm (w) || IS_MOVL_RnRm (w))
&& (w & 0x70) <= 0x20 /* Rs is R0, R1 or R2 */
if (IS_MOVB_Rn16_SP (w)
&& 8 <= (w & 0xf) && (w & 0xf) <= 10) /* Rs is R0L, R1L, or R2L */
{
- if (read_memory_integer (pc + 2, 2) < 0) /* ... and d:16 is negative. */
+ /* ... and d:16 is negative. */
+ if (read_memory_integer (pc + 2, 2, byte_order) < 0)
return 4;
}
else if (IS_MOVB_EXT (w))
{
- if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2)))
+ if (IS_MOVB_Rn24_SP (read_memory_unsigned_integer (pc + 2,
+ 2, byte_order)))
{
- LONGEST disp = read_memory_integer (pc + 4, 4);
+ LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
/* ... and d:24 is negative. */
if (disp < 0 && disp > 0xffffff)
&& (w & 0xf) <= 2) /* Rs is R0, R1, or R2 */
{
/* ... and d:16 is negative. */
- if (read_memory_integer (pc + 2, 2) < 0)
+ if (read_memory_integer (pc + 2, 2, byte_order) < 0)
return 4;
}
else if (IS_MOVW_EXT (w))
{
- if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2, 2)))
+ if (IS_MOVW_Rn24_SP (read_memory_unsigned_integer (pc + 2,
+ 2, byte_order)))
{
- LONGEST disp = read_memory_integer (pc + 4, 4);
+ LONGEST disp = read_memory_integer (pc + 4, 4, byte_order);
/* ... and d:24 is negative. */
if (disp < 0 && disp > 0xffffff)
}
else if (IS_MOVL_PRE (w))
{
- int w2 = read_memory_integer (pc + 2, 2);
+ int w2 = read_memory_integer (pc + 2, 2, byte_order);
if (IS_MOVL_Rn16_SP (w2)
&& (w2 & 0xf) <= 2) /* Rs is ER0, ER1, or ER2 */
{
/* ... and d:16 is negative. */
- if (read_memory_integer (pc + 4, 2) < 0)
+ if (read_memory_integer (pc + 4, 2, byte_order) < 0)
return 6;
}
else if (IS_MOVL_EXT (w2))
{
- int w3 = read_memory_integer (pc + 4, 2);
+ int w3 = read_memory_integer (pc + 4, 2, byte_order);
- if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2)))
+ if (IS_MOVL_Rn24_SP (read_memory_integer (pc + 4, 2, byte_order)))
{
- LONGEST disp = read_memory_integer (pc + 6, 4);
+ LONGEST disp = read_memory_integer (pc + 6, 4, byte_order);
/* ... and d:24 is negative. */
if (disp < 0 && disp > 0xffffff)
*/
static CORE_ADDR
-h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+h8300_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR current_pc,
struct h8300_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int op;
int regno, i, spill_size;
if (pc >= current_pc)
return current_pc;
- op = read_memory_unsigned_integer (pc, 4);
+ op = read_memory_unsigned_integer (pc, 4, byte_order);
if (IS_PUSHFP_MOVESPFP (op))
{
pc += 4;
if (pc >= current_pc)
return current_pc;
- op = read_memory_unsigned_integer (pc, 2);
+ op = read_memory_unsigned_integer (pc, 2, byte_order);
if (IS_MOV_SP_FP (op))
{
cache->uses_fp = 1;
while (pc < current_pc)
{
- op = read_memory_unsigned_integer (pc, 2);
+ op = read_memory_unsigned_integer (pc, 2, byte_order);
if (IS_SUB2_SP (op))
{
cache->sp_offset += 2;
}
else if (IS_ADD_IMM_SP (op))
{
- cache->sp_offset += -read_memory_integer (pc + 2, 2);
+ cache->sp_offset += -read_memory_integer (pc + 2, 2, byte_order);
pc += 4;
}
else if (IS_SUB_IMM_SP (op))
{
- cache->sp_offset += read_memory_integer (pc + 2, 2);
+ cache->sp_offset += read_memory_integer (pc + 2, 2, byte_order);
pc += 4;
}
else if (IS_SUBL4_SP (op))
}
else if (IS_MOV_IMM_Rn (op))
{
- int offset = read_memory_integer (pc + 2, 2);
+ int offset = read_memory_integer (pc + 2, 2, byte_order);
regno = op & 0x000f;
- op = read_memory_unsigned_integer (pc + 4, 2);
+ op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
if (IS_ADD_RnSP (op) && (op & 0x00f0) == regno)
{
cache->sp_offset -= offset;
}
else if (op == 0x0100)
{
- op = read_memory_unsigned_integer (pc + 2, 2);
+ op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
if (IS_PUSH (op))
{
regno = op & 0x000f;
else if ((op & 0xffcf) == 0x0100)
{
int op1;
- op1 = read_memory_unsigned_integer (pc + 2, 2);
+ op1 = read_memory_unsigned_integer (pc + 2, 2, byte_order);
if (IS_PUSH (op1))
{
/* Since the prefix is 0x01x0, this is not a simple pushm but a
/* Check for spilling an argument register to the stack frame.
This could also be an initializing store from non-prologue code,
but I don't think there's any harm in skipping that. */
- while ((spill_size = h8300_is_argument_spill (pc)) > 0
+ while ((spill_size = h8300_is_argument_spill (gdbarch, pc)) > 0
&& pc + spill_size <= current_pc)
pc += spill_size;
cache->pc = get_frame_func (this_frame);
current_pc = get_frame_pc (this_frame);
if (cache->pc != 0)
- h8300_analyze_prologue (cache->pc, current_pc, cache);
+ h8300_analyze_prologue (gdbarch, cache->pc, current_pc, cache);
if (!cache->uses_fp)
{
/* No useable line symbol. Use prologue parsing method. */
h8300_init_frame_cache (gdbarch, &cache);
- return h8300_analyze_prologue (func_addr, func_end, &cache);
+ return h8300_analyze_prologue (gdbarch, func_addr, func_end, &cache);
}
/* No function symbol -- just return the PC. */
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_alloc = 0, stack_offset = 0;
int wordsize = BINWORD (gdbarch);
int reg = E_ARG0_REGNUM;
for (offset = 0; offset < padded_len; offset += wordsize)
{
- ULONGEST word = extract_unsigned_integer (padded + offset,
- wordsize);
+ ULONGEST word
+ = extract_unsigned_integer (padded + offset,
+ wordsize, byte_order);
regcache_cooked_write_unsigned (regcache, reg++, word);
}
}
/* Store return address. */
sp -= wordsize;
- write_memory_unsigned_integer (sp, wordsize, bp_addr);
+ write_memory_unsigned_integer (sp, wordsize, byte_order, bp_addr);
/* Update stack pointer. */
regcache_cooked_write_unsigned (regcache, E_SP_REGNUM, sp);
h8300_extract_return_value (struct type *type, struct regcache *regcache,
void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
ULONGEST c, addr;
case 1:
case 2:
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
- store_unsigned_integer (valbuf, len, c);
+ store_unsigned_integer (valbuf, len, byte_order, c);
break;
case 4: /* Needs two registers on plain H8/300 */
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
- store_unsigned_integer (valbuf, 2, c);
+ store_unsigned_integer (valbuf, 2, byte_order, c);
regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
- store_unsigned_integer ((void *) ((char *) valbuf + 2), 2, c);
+ store_unsigned_integer ((void *)((char *) valbuf + 2), 2, byte_order, c);
break;
case 8: /* long long is now 8 bytes. */
if (TYPE_CODE (type) == TYPE_CODE_INT)
{
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &addr);
- c = read_memory_unsigned_integer ((CORE_ADDR) addr, len);
- store_unsigned_integer (valbuf, len, c);
+ c = read_memory_unsigned_integer ((CORE_ADDR) addr, len, byte_order);
+ store_unsigned_integer (valbuf, len, byte_order, c);
}
else
{
h8300h_extract_return_value (struct type *type, struct regcache *regcache,
void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
ULONGEST c, addr;
case 2:
case 4:
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
- store_unsigned_integer (valbuf, len, c);
+ store_unsigned_integer (valbuf, len, byte_order, c);
break;
case 8: /* long long is now 8 bytes. */
if (TYPE_CODE (type) == TYPE_CODE_INT)
{
regcache_cooked_read_unsigned (regcache, E_RET0_REGNUM, &c);
- store_unsigned_integer (valbuf, 4, c);
+ store_unsigned_integer (valbuf, 4, byte_order, c);
regcache_cooked_read_unsigned (regcache, E_RET1_REGNUM, &c);
- store_unsigned_integer ((void *) ((char *) valbuf + 4), 4, c);
+ store_unsigned_integer ((void *) ((char *) valbuf + 4), 4,
+ byte_order, c);
}
else
{
h8300_store_return_value (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
ULONGEST val;
{
case 1:
case 2: /* short... */
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
break;
case 4: /* long, float */
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
(val >> 16) & 0xffff);
regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM, val & 0xffff);
h8300h_store_return_value (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
ULONGEST val;
case 1:
case 2:
case 4: /* long, float */
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM, val);
break;
case 8:
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, E_RET0_REGNUM,
(val >> 32) & 0xffffffff);
regcache_cooked_write_unsigned (regcache, E_RET1_REGNUM,
hppa_hpux_fetch_register (struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
`struct save_state', even for 64-bit code. */
if (regnum == HPPA_FLAGS_REGNUM && size == 8)
{
- ULONGEST flags = extract_unsigned_integer ((gdb_byte *)buf, 4);
- store_unsigned_integer ((gdb_byte *)buf, 8, flags);
+ ULONGEST flags;
+ flags = extract_unsigned_integer ((gdb_byte *)buf, 4, byte_order);
+ store_unsigned_integer ((gdb_byte *)buf, 8, byte_order, flags);
}
regcache_raw_supply (regcache, regnum, buf);
hppa_hpux_store_register (struct regcache *regcache, int regnum)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR addr;
size_t size;
PTRACE_TYPE_RET *buf;
`struct save_state', even for 64-bit code. */
if (regnum == HPPA_FLAGS_REGNUM && size == 8)
{
- ULONGEST flags = extract_unsigned_integer ((gdb_byte *)buf, 8);
- store_unsigned_integer ((gdb_byte *)buf, 4, flags);
+ ULONGEST flags;
+ flags = extract_unsigned_integer ((gdb_byte *)buf, 8, byte_order);
+ store_unsigned_integer ((gdb_byte *)buf, 4, byte_order, flags);
size = 4;
}
just shared library trampolines (import, export). */
static int
-hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa32_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct minimal_symbol *minsym;
struct unwind_table_entry *u;
{
unsigned long insn;
- insn = read_memory_integer (addr, 4);
+ insn = read_memory_integer (addr, 4, byte_order);
/* Does it look like a bl? If so then it's the call path, if
we find a bv or be first, then we're on the return path. */
}
static int
-hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa64_hpux_in_solib_call_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* PA64 has a completely different stub/trampoline scheme. Is it
better? Maybe. It's certainly harder to determine with any
certainty that we are in a stub because we can not refer to the
/* We might be in a stub. Peek at the instructions. Stubs are 3
instructions long. */
- insn = read_memory_integer (pc, 4);
+ insn = read_memory_integer (pc, 4, byte_order);
/* Find out where we think we are within the stub. */
if ((insn & 0xffffc00e) == 0x53610000)
return 0;
/* Now verify each insn in the range looks like a stub instruction. */
- insn = read_memory_integer (addr, 4);
+ insn = read_memory_integer (addr, 4, byte_order);
if ((insn & 0xffffc00e) != 0x53610000)
return 0;
/* Now verify each insn in the range looks like a stub instruction. */
- insn = read_memory_integer (addr + 4, 4);
+ insn = read_memory_integer (addr + 4, 4, byte_order);
if ((insn & 0xffffffff) != 0xe820d000)
return 0;
/* Now verify each insn in the range looks like a stub instruction. */
- insn = read_memory_integer (addr + 8, 4);
+ insn = read_memory_integer (addr + 8, 4, byte_order);
if ((insn & 0xffffc00e) != 0x537b0000)
return 0;
just shared library trampolines (import, export). */
static int
-hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+hppa_hpux_in_solib_return_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct unwind_table_entry *u;
/* Get the unwind descriptor corresponding to PC, return zero
{
unsigned long insn;
- insn = read_memory_integer (addr, 4);
+ insn = read_memory_integer (addr, 4, byte_order);
/* Does it look like a bl? If so then it's the call path, if
we find a bv or be first, then we're on the return path. */
hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int word_size = gdbarch_ptr_bit (gdbarch) / 8;
long orig_pc = pc;
long prev_inst, curr_inst, loc;
struct minimal_symbol *msym;
the PLT entry for this function, not the address of the function
itself. Bit 31 has meaning too, but only for MPE. */
if (pc & 0x2)
- pc = (CORE_ADDR) read_memory_integer
- (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
+ pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
}
if (pc == hppa_symbol_address("$$dyncall_external"))
{
pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
- pc = (CORE_ADDR) read_memory_integer
- (pc & ~0x3, gdbarch_ptr_bit (gdbarch) / 8);
+ pc = (CORE_ADDR) read_memory_integer (pc & ~0x3, word_size, byte_order);
}
else if (pc == hppa_symbol_address("_sr4export"))
pc = (CORE_ADDR) get_frame_register_unsigned (frame, 22);
}
prev_inst = curr_inst;
- curr_inst = read_memory_integer (loc, 4);
+ curr_inst = read_memory_integer (loc, 4, byte_order);
/* Does it look like a branch external using %r1? Then it's the
branch from the stub to the actual function. */
{
CORE_ADDR sp;
sp = get_frame_register_unsigned (frame, HPPA_SP_REGNUM);
- return read_memory_integer (sp - 8, 4) & ~0x3;
+ return read_memory_integer (sp - 8, 4, byte_order) & ~0x3;
}
else
{
{
return (read_memory_integer
(get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
- gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
+ word_size, byte_order)) & ~0x3;
}
/* What about be,n 0(sr0,%rp)? It's just another way we return to
mtsp %r1,%sr0 if we want to do sanity checking. */
return (read_memory_integer
(get_frame_register_unsigned (frame, HPPA_SP_REGNUM) - 24,
- gdbarch_ptr_bit (gdbarch) / 8)) & ~0x3;
+ word_size, byte_order)) & ~0x3;
}
/* Haven't found the branch yet, but we're still in the stub.
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct hppa_hpux_sigtramp_unwind_cache *info;
unsigned int flag;
CORE_ADDR sp, scptr, off;
/* See /usr/include/machine/save_state.h for the structure of the save_state_t
structure. */
- flag = read_memory_unsigned_integer(scptr + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+ flag = read_memory_unsigned_integer (scptr + HPPA_HPUX_SS_FLAGS_OFFSET,
+ 4, byte_order);
if (!(flag & HPPA_HPUX_SS_WIDEREGS))
{
struct frame_info *this_frame,
void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct unwind_table_entry *u;
CORE_ADDR pc = get_frame_pc (this_frame);
buf, sizeof buf))
return 0;
- insn = extract_unsigned_integer (buf, sizeof buf);
+ insn = extract_unsigned_integer (buf, sizeof buf, byte_order);
if ((insn & 0xffe0e000) == 0xe8400000)
u = find_unwind_entry(u->region_start + hppa_extract_17 (insn) + 8);
}
hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
struct value *function)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR faddr;
faddr = value_as_address (function);
status = target_read_memory (faddr + 4, buf, sizeof (buf));
if (status == 0)
- return extract_unsigned_integer (buf, sizeof (buf));
+ return extract_unsigned_integer (buf, sizeof (buf), byte_order);
}
return gdbarch_tdep (gdbarch)->solib_get_got_by_pc (faddr);
hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
struct value *function)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR faddr;
char buf[32];
if (in_opd_section (faddr))
{
target_read_memory (faddr, buf, sizeof (buf));
- return extract_unsigned_integer (&buf[24], 8);
+ return extract_unsigned_integer (&buf[24], 8, byte_order);
}
else
{
};
static CORE_ADDR
-hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end,
+hppa_hpux_search_pattern (struct gdbarch *gdbarch,
+ CORE_ADDR start, CORE_ADDR end,
unsigned int *patterns, int count)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int num_insns = (end - start + HPPA_INSN_SIZE) / HPPA_INSN_SIZE;
unsigned int *insns;
gdb_byte *buf;
read_memory (start, buf, num_insns * HPPA_INSN_SIZE);
for (i = 0; i < num_insns; i++, buf += HPPA_INSN_SIZE)
- insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
+ insns[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
for (offset = 0; offset <= num_insns - count; offset++)
{
hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
int *argreg)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct objfile *obj;
struct obj_section *sec;
struct hppa_objfile_private *priv;
u = find_unwind_entry (rp);
if (u && u->stub_unwind.stub_type == EXPORT)
{
- addr = hppa_hpux_search_pattern (u->region_start, u->region_end,
+ addr = hppa_hpux_search_pattern (gdbarch,
+ u->region_start, u->region_end,
ldsid_pattern,
ARRAY_SIZE (ldsid_pattern));
if (addr)
u = &priv->unwind_info->table[i];
if (u->stub_unwind.stub_type == EXPORT)
{
- addr = hppa_hpux_search_pattern (u->region_start, u->region_end,
+ addr = hppa_hpux_search_pattern (gdbarch,
+ u->region_start, u->region_end,
ldsid_pattern,
ARRAY_SIZE (ldsid_pattern));
if (addr)
find_pc_partial_function (addr, NULL, &start, &end);
if (start != 0 && end != 0)
{
- addr = hppa_hpux_search_pattern (start, end, ldsid_pattern,
+ addr = hppa_hpux_search_pattern (gdbarch, start, end, ldsid_pattern,
ARRAY_SIZE (ldsid_pattern));
if (addr)
goto found_pattern;
found_pattern:
target_read_memory (addr, buf, sizeof (buf));
- insn = extract_unsigned_integer (buf, sizeof (buf));
+ insn = extract_unsigned_integer (buf, sizeof (buf), byte_order);
priv->dummy_call_sequence_addr = addr;
priv->dummy_call_sequence_reg = (insn >> 21) & 0x1f;
hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
int *argreg)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct objfile *obj;
struct obj_section *sec;
struct hppa_objfile_private *priv;
{
unsigned int insn;
- insn = extract_unsigned_integer (buf + offset, HPPA_INSN_SIZE);
+ insn = extract_unsigned_integer (buf + offset,
+ HPPA_INSN_SIZE, byte_order);
if (insn == 0xe840d002) /* bve,n (rp) */
{
addr = (end - sizeof (buf)) + offset;
struct regcache *regcache,
int regnum, const void *regs, size_t len)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const char *proc_info = regs;
const char *save_state = proc_info + 8;
ULONGEST flags;
- flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET, 4);
+ flags = extract_unsigned_integer (save_state + HPPA_HPUX_SS_FLAGS_OFFSET,
+ 4, byte_order);
if (regnum == -1 || regnum == HPPA_FLAGS_REGNUM)
{
- struct gdbarch *arch = get_regcache_arch (regcache);
- size_t size = register_size (arch, HPPA_FLAGS_REGNUM);
+ size_t size = register_size (gdbarch, HPPA_FLAGS_REGNUM);
char buf[8];
- store_unsigned_integer (buf, size, flags);
+ store_unsigned_integer (buf, size, byte_order, flags);
regcache_raw_supply (regcache, HPPA_FLAGS_REGNUM, buf);
}
struct trad_frame_saved_reg *saved_regs)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int word_size = gdbarch_ptr_bit (gdbarch) / 8;
struct value *pcoq_head_val;
ULONGEST pcoq_head;
CORE_ADDR stubpc;
HPPA_PCOQ_HEAD_REGNUM);
pcoq_head =
extract_unsigned_integer (value_contents_all (pcoq_head_val),
- register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM));
+ register_size (gdbarch, HPPA_PCOQ_HEAD_REGNUM),
+ byte_order);
u = find_unwind_entry (pcoq_head);
if (u && u->stub_unwind.stub_type == EXPORT)
{
- stubpc = read_memory_integer (base - 24, gdbarch_ptr_bit (gdbarch) / 8);
+ stubpc = read_memory_integer (base - 24, word_size, byte_order);
trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
}
else if (hppa_symbol_address ("__gcc_plt_call")
== get_pc_function_start (pcoq_head))
{
- stubpc = read_memory_integer
- (base - 8, gdbarch_ptr_bit (gdbarch) / 8);
+ stubpc = read_memory_integer (base - 8, word_size, byte_order);
trad_frame_set_value (saved_regs, HPPA_PCOQ_HEAD_REGNUM, stubpc);
}
}
When the match is successful, fill INSN[i] with what PATTERN[i]
matched. */
static int
-insns_match_pattern (CORE_ADDR pc,
+insns_match_pattern (struct gdbarch *gdbarch, CORE_ADDR pc,
struct insn_pattern *pattern,
unsigned int *insn)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
CORE_ADDR npc = pc;
char buf[4];
target_read_memory (npc, buf, 4);
- insn[i] = extract_unsigned_integer (buf, 4);
+ insn[i] = extract_unsigned_integer (buf, 4, byte_order);
if ((insn[i] & pattern[i].mask) == pattern[i].data)
npc += 4;
else
Note that with a 2.4 64-bit kernel, the signal context is not properly
passed back to userspace so the unwind will not work correctly. */
static CORE_ADDR
-hppa_linux_sigtramp_find_sigcontext (CORE_ADDR pc)
+hppa_linux_sigtramp_find_sigcontext (struct gdbarch *gdbarch, CORE_ADDR pc)
{
unsigned int dummy[HPPA_MAX_INSN_PATTERN_LEN];
int offs = 0;
for (try = 0; try < ARRAY_SIZE (pcoffs); try++)
{
- if (insns_match_pattern (sp + pcoffs[try], hppa_sigtramp, dummy))
+ if (insns_match_pattern (gdbarch, sp + pcoffs[try],
+ hppa_sigtramp, dummy))
{
offs = sfoffs[try];
break;
if (offs == 0)
{
- if (insns_match_pattern (pc, hppa_sigtramp, dummy))
+ if (insns_match_pattern (gdbarch, pc, hppa_sigtramp, dummy))
{
/* sigaltstack case: we have no way of knowing which offset to
use in this case; default to new kernel handling. If this is
info->saved_regs = trad_frame_alloc_saved_regs (this_frame);
pc = get_frame_pc (this_frame);
- scptr = hppa_linux_sigtramp_find_sigcontext (pc);
+ scptr = hppa_linux_sigtramp_find_sigcontext (gdbarch, pc);
/* structure of struct sigcontext:
struct frame_info *this_frame,
void **this_prologue_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
CORE_ADDR pc = get_frame_pc (this_frame);
- if (hppa_linux_sigtramp_find_sigcontext (pc))
+ if (hppa_linux_sigtramp_find_sigcontext (gdbarch, pc))
return 1;
return 0;
static CORE_ADDR
hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *faddr_sect;
CORE_ADDR faddr;
status = target_read_memory (faddr + 4, buf, sizeof (buf));
if (status == 0)
- return extract_unsigned_integer (buf, sizeof (buf));
+ return extract_unsigned_integer (buf, sizeof (buf), byte_order);
}
/* If the address is in the plt section, then the real function hasn't
status = target_read_memory (addr, buf, sizeof (buf));
if (status != 0)
break;
- tag = extract_signed_integer (buf, sizeof (buf));
+ tag = extract_signed_integer (buf, sizeof (buf), byte_order);
if (tag == DT_PLTGOT)
{
status = target_read_memory (addr + 4, buf, sizeof (buf));
if (status != 0)
break;
- global_pointer = extract_unsigned_integer (buf, sizeof (buf));
-
+ global_pointer = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
/* The payoff... */
return global_pointer;
}
static int
hppa_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long status;
unsigned int inst;
char buf[4];
if (status != 0)
return 0;
- inst = extract_unsigned_integer (buf, 4);
+ inst = extract_unsigned_integer (buf, 4, byte_order);
/* The most common way to perform a stack adjustment ldo X(sp),sp
We are destroying a stack frame if the offset is negative. */
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* Stack base address at which any pass-by-reference parameters are
stored. */
CORE_ADDR struct_end = 0;
if (write_pass)
write_memory (struct_end - struct_ptr, value_contents (arg),
TYPE_LENGTH (type));
- store_unsigned_integer (param_val, 4, struct_end - struct_ptr);
+ store_unsigned_integer (param_val, 4, byte_order,
+ struct_end - struct_ptr);
}
else if (TYPE_CODE (type) == TYPE_CODE_INT
|| TYPE_CODE (type) == TYPE_CODE_ENUM)
/* Integer value store, right aligned. "unpack_long"
takes care of any sign-extension problems. */
param_len = align_up (TYPE_LENGTH (type), 4);
- store_unsigned_integer (param_val, param_len,
+ store_unsigned_integer (param_val, param_len, byte_order,
unpack_long (type,
value_contents (arg)));
}
function descriptor and return its address instead. If CODE is not a
function entry address, then just return it unchanged. */
static CORE_ADDR
-hppa64_convert_code_addr_to_fptr (CORE_ADDR code)
+hppa64_convert_code_addr_to_fptr (struct gdbarch *gdbarch, CORE_ADDR code)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *sec, *opd;
sec = find_pc_section (code);
if (target_read_memory (addr, tmp, sizeof (tmp)))
break;
- opdaddr = extract_unsigned_integer (tmp, sizeof (tmp));
+ opdaddr = extract_unsigned_integer (tmp, sizeof (tmp), byte_order);
if (opdaddr == code)
return addr - 16;
int struct_return, CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i, offset = 0;
CORE_ADDR gp;
ULONGEST codeptr, fptr;
codeptr = unpack_long (type, value_contents (arg));
- fptr = hppa64_convert_code_addr_to_fptr (codeptr);
- store_unsigned_integer (fptrbuf, TYPE_LENGTH (type), fptr);
+ fptr = hppa64_convert_code_addr_to_fptr (gdbarch, codeptr);
+ store_unsigned_integer (fptrbuf, TYPE_LENGTH (type), byte_order,
+ fptr);
valbuf = fptrbuf;
}
else
skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR pc,
int stop_before_branch)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[4];
CORE_ADDR orig_pc = pc;
unsigned long inst, stack_remaining, save_gr, save_fr, save_rp, save_sp;
old_stack_remaining = stack_remaining;
status = target_read_memory (pc, buf, 4);
- inst = extract_unsigned_integer (buf, 4);
+ inst = extract_unsigned_integer (buf, 4, byte_order);
/* Yow! */
if (status != 0)
{
pc += 4;
status = target_read_memory (pc, buf, 4);
- inst = extract_unsigned_integer (buf, 4);
+ inst = extract_unsigned_integer (buf, 4, byte_order);
if (status != 0)
return pc;
reg_num = inst_saves_gr (inst);
save_fr &= ~(1 << reg_num);
status = target_read_memory (pc + 4, buf, 4);
- next_inst = extract_unsigned_integer (buf, 4);
+ next_inst = extract_unsigned_integer (buf, 4, byte_order);
/* Yow! */
if (status != 0)
{
pc += 8;
status = target_read_memory (pc, buf, 4);
- inst = extract_unsigned_integer (buf, 4);
+ inst = extract_unsigned_integer (buf, 4, byte_order);
if (status != 0)
return pc;
if ((inst & 0xfc000000) != 0x34000000)
break;
status = target_read_memory (pc + 4, buf, 4);
- next_inst = extract_unsigned_integer (buf, 4);
+ next_inst = extract_unsigned_integer (buf, 4, byte_order);
if (status != 0)
return pc;
reg_num = inst_saves_fr (next_inst);
hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int word_size = gdbarch_ptr_bit (gdbarch) / 8;
struct hppa_frame_cache *cache;
long saved_gr_mask;
long saved_fr_mask;
return (*this_cache);
}
- inst = extract_unsigned_integer (buf4, sizeof buf4);
+ inst = extract_unsigned_integer (buf4, sizeof buf4, byte_order);
/* Note the interesting effects of this instruction. */
frame_size += prologue_inst_adjust_sp (inst);
/* Both we're expecting the SP to be saved and the SP has been
saved. The entry SP value is saved at this frame's SP
address. */
- cache->base = read_memory_integer
- (this_sp, gdbarch_ptr_bit (gdbarch) / 8);
+ cache->base = read_memory_integer (this_sp, word_size, byte_order);
if (hppa_debug)
fprintf_unfiltered (gdb_stdlog, " (base=%s) [saved]",
static struct hppa_frame_cache *
hppa_fallback_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct hppa_frame_cache *cache;
unsigned int frame_size = 0;
int found_rp = 0;
{
unsigned int insn;
- insn = read_memory_unsigned_integer (pc, 4);
+ insn = read_memory_unsigned_integer (pc, 4, byte_order);
frame_size += prologue_inst_adjust_sp (insn);
/* There are limited ways to store the return pointer into the
if (pc == 0
|| (tdep->in_solib_call_trampoline != NULL
- && tdep->in_solib_call_trampoline (pc, NULL))
+ && tdep->in_solib_call_trampoline (gdbarch, pc, NULL))
|| gdbarch_in_solib_return_trampoline (gdbarch, pc, NULL))
return 1;
return 0;
hppa_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST tmp;
regcache_raw_read_unsigned (regcache, regnum, &tmp);
if (regnum == HPPA_PCOQ_HEAD_REGNUM || regnum == HPPA_PCOQ_TAIL_REGNUM)
tmp &= ~0x3;
- store_unsigned_integer (buf, sizeof tmp, tmp);
+ store_unsigned_integer (buf, sizeof tmp, byte_order, tmp);
}
static CORE_ADDR
int regnum)
{
struct gdbarch *arch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (arch);
if (regnum == HPPA_PCOQ_TAIL_REGNUM)
{
trad_frame_get_prev_register (this_frame, saved_regs,
HPPA_PCOQ_HEAD_REGNUM);
- pc = extract_unsigned_integer (value_contents_all (pcoq_val), size);
+ pc = extract_unsigned_integer (value_contents_all (pcoq_val),
+ size, byte_order);
return frame_unwind_got_constant (this_frame, regnum, pc + 4);
}
matched. */
static int
-hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
- unsigned int *insn)
+hppa_match_insns (struct gdbarch *gdbarch, CORE_ADDR pc,
+ struct insn_pattern *pattern, unsigned int *insn)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR npc = pc;
int i;
gdb_byte buf[HPPA_INSN_SIZE];
target_read_memory (npc, buf, HPPA_INSN_SIZE);
- insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE);
+ insn[i] = extract_unsigned_integer (buf, HPPA_INSN_SIZE, byte_order);
if ((insn[i] & pattern[i].mask) == pattern[i].data)
npc += 4;
else
instruction scheme. */
static int
-hppa_match_insns_relaxed (CORE_ADDR pc, struct insn_pattern *pattern,
- unsigned int *insn)
+hppa_match_insns_relaxed (struct gdbarch *gdbarch, CORE_ADDR pc,
+ struct insn_pattern *pattern, unsigned int *insn)
{
int offset, len = 0;
len++;
for (offset = 0; offset < len; offset++)
- if (hppa_match_insns (pc - offset * HPPA_INSN_SIZE, pattern, insn))
+ if (hppa_match_insns (gdbarch, pc - offset * HPPA_INSN_SIZE,
+ pattern, insn))
return 1;
return 0;
}
int
-hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name)
+hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
unsigned int insn[HPPA_MAX_INSN_PATTERN_LEN];
struct unwind_table_entry *u;
if (u != NULL)
return 0;
- return (hppa_match_insns_relaxed (pc, hppa_import_stub, insn)
- || hppa_match_insns_relaxed (pc, hppa_import_pic_stub, insn)
- || hppa_match_insns_relaxed (pc, hppa_long_branch_stub, insn)
- || hppa_match_insns_relaxed (pc, hppa_long_branch_pic_stub, insn));
+ return
+ (hppa_match_insns_relaxed (gdbarch, pc, hppa_import_stub, insn)
+ || hppa_match_insns_relaxed (gdbarch, pc, hppa_import_pic_stub, insn)
+ || hppa_match_insns_relaxed (gdbarch, pc, hppa_long_branch_stub, insn)
+ || hppa_match_insns_relaxed (gdbarch, pc,
+ hppa_long_branch_pic_stub, insn));
}
/* This code skips several kind of "trampolines" used on PA-RISC
return pc;
}
- dp_rel = hppa_match_insns (pc, hppa_import_stub, insn);
- if (dp_rel || hppa_match_insns (pc, hppa_import_pic_stub, insn))
+ dp_rel = hppa_match_insns (gdbarch, pc, hppa_import_stub, insn);
+ if (dp_rel || hppa_match_insns (gdbarch, pc, hppa_import_pic_stub, insn))
{
/* Extract the target address from the addil/ldw sequence. */
pc = hppa_extract_21 (insn[0]) + hppa_extract_14 (insn[1]);
if (in_plt_section (pc, NULL))
{
/* Sanity check: are we pointing to the PLT stub? */
- if (!hppa_match_insns (pc, hppa_plt_stub, insn))
+ if (!hppa_match_insns (gdbarch, pc, hppa_plt_stub, insn))
{
warning (_("Cannot resolve PLT stub at %s."),
paddress (gdbarch, pc));
trampoline code in the ".plt", or equivalent, section.
IN_SOLIB_CALL_TRAMPOLINE evaluates to nonzero if we are currently
stopped in one of these. */
- int (*in_solib_call_trampoline) (CORE_ADDR pc, char *name);
+ int (*in_solib_call_trampoline) (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name);
/* For targets that support multiple spaces, we may have additional stubs
in the return path. These stubs are internal to the ABI, and users are
extern struct hppa_objfile_private *
hppa_init_objfile_priv_data (struct objfile *objfile);
-extern int hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name);
+extern int hppa_in_solib_call_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name);
extern CORE_ADDR hppa_skip_trampoline_code (struct frame_info *, CORE_ADDR pc);
#endif /* hppa-tdep.h */
static CORE_ADDR
hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR faddr = value_as_address (function);
struct obj_section *faddr_sec;
gdb_byte buf[4];
if (faddr & 2)
{
if (target_read_memory ((faddr & ~3) + 4, buf, sizeof buf) == 0)
- return extract_unsigned_integer (buf, sizeof buf);
+ return extract_unsigned_integer (buf, sizeof buf, byte_order);
}
/* If the address is in the .plt section, then the real function
if (target_read_memory (addr, buf, sizeof buf) != 0)
break;
- tag = extract_signed_integer (buf, sizeof buf);
+ tag = extract_signed_integer (buf, sizeof buf, byte_order);
if (tag == DT_PLTGOT)
{
CORE_ADDR pltgot;
/* The NetBSD/OpenBSD ld.so doesn't relocate DT_PLTGOT, so
we have to do it ourselves. */
- pltgot = extract_unsigned_integer (buf, sizeof buf);
+ pltgot = extract_unsigned_integer (buf, sizeof buf,
+ byte_order);
pltgot += ANOFFSET (sec->objfile->section_offsets,
SECT_OFF_TEXT (sec->objfile));
struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
cma__t_int_tcb tcb, *tcb_ptr;
struct cleanup *old_chain;
int i;
/* Flags must be 0 to avoid bogus value for SS_INSYSCALL */
memset (buf, '\000', register_size (gdbarch, regno));
else if (regno == HPPA_SP_REGNUM)
- store_unsigned_integer (buf, sizeof sp, sp);
+ store_unsigned_integer (buf, sizeof sp, byte_order, sp);
else if (regno == HPPA_PCOQ_HEAD_REGNUM)
read_memory (sp - 20, buf, register_size (gdbarch, regno));
else
core_process_module_section (bfd *abfd, asection *sect, void *obj)
{
struct cpms_data *data = obj;
+ enum bfd_endian byte_order = gdbarch_byte_order (data->gdbarch);
char *module_name;
size_t module_name_size;
/* A DWORD (data_type) followed by struct windows_core_module_info. */
base_addr =
- extract_unsigned_integer (buf + 4, 4);
+ extract_unsigned_integer (buf + 4, 4, byte_order);
module_name_size =
- extract_unsigned_integer (buf + 8, 4);
+ extract_unsigned_integer (buf + 8, 4, byte_order);
module_name = buf + 12;
if (module_name - buf + module_name_size > bfd_get_section_size (sect))
static CORE_ADDR
i386_cygwin_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
- return i386_pe_skip_trampoline_code (pc, NULL);
+ return i386_pe_skip_trampoline_code (frame, pc, NULL);
}
static void
static int
i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
static const gdb_byte darwin_syscall[] = { 0xcd, 0x80 }; /* int 0x80 */
gdb_byte buf[sizeof (darwin_syscall)];
ULONGEST flags_addr;
unsigned int eflags;
- uctx_addr = read_memory_unsigned_integer (regs->uts.ts32.__esp + 4, 4);
- mctx_addr = read_memory_unsigned_integer (uctx_addr + 28, 4);
+ uctx_addr = read_memory_unsigned_integer
+ (regs->uts.ts32.__esp + 4, 4, byte_order);
+ mctx_addr = read_memory_unsigned_integer
+ (uctx_addr + 28, 4, byte_order);
flags_addr = mctx_addr + 12 + 9 * 4;
read_memory (flags_addr, (gdb_byte *) &eflags, 4);
static int
amd64_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
static const gdb_byte darwin_syscall[] = { 0x0f, 0x05 }; /* syscall */
gdb_byte buf[sizeof (darwin_syscall)];
ULONGEST flags_addr;
unsigned int rflags;
- mctx_addr = read_memory_unsigned_integer (regs->uts.ts64.__rdi + 48, 8);
+ mctx_addr = read_memory_unsigned_integer
+ (regs->uts.ts64.__rdi + 48, 8, byte_order);
flags_addr = mctx_addr + 16 + 17 * 8;
/* AMD64 is little endian. */
static CORE_ADDR
i386_darwin_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR bp;
CORE_ADDR si;
gdb_byte buf[4];
get_frame_register (this_frame, I386_EBP_REGNUM, buf);
- bp = extract_unsigned_integer (buf, 4);
+ bp = extract_unsigned_integer (buf, 4, byte_order);
/* A pointer to the ucontext is passed as the fourth argument
to the signal handler. */
read_memory (bp + 24, buf, 4);
- si = extract_unsigned_integer (buf, 4);
+ si = extract_unsigned_integer (buf, 4, byte_order);
/* The pointer to mcontext is at offset 28. */
read_memory (si + 28, buf, 4);
/* First register (eax) is at offset 12. */
- return extract_unsigned_integer (buf, 4) + 12;
+ return extract_unsigned_integer (buf, 4, byte_order) + 12;
}
static CORE_ADDR
amd64_darwin_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR rbx;
CORE_ADDR si;
gdb_byte buf[8];
/* A pointer to the ucontext is passed as the fourth argument
to the signal handler, which is saved in rbx. */
get_frame_register (this_frame, AMD64_RBX_REGNUM, buf);
- rbx = extract_unsigned_integer (buf, 8);
+ rbx = extract_unsigned_integer (buf, 8, byte_order);
/* The pointer to mcontext is at offset 48. */
read_memory (rbx + 48, buf, 8);
/* First register (rax) is at offset 16. */
- return extract_unsigned_integer (buf, 8) + 16;
+ return extract_unsigned_integer (buf, 8, byte_order) + 16;
}
/* Return true if the PC of THIS_FRAME is in a signal trampoline which
if (step)
{
struct regcache *regcache = get_thread_regcache (pid_to_ptid (pid));
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST pc;
gdb_byte buf[LINUX_SYSCALL_LEN];
request = PTRACE_SINGLESTEP;
- regcache_cooked_read_unsigned
- (regcache, gdbarch_pc_regnum (get_regcache_arch (regcache)), &pc);
+ regcache_cooked_read_unsigned (regcache,
+ gdbarch_pc_regnum (gdbarch), &pc);
/* Returning from a signal trampoline is done by calling a
special system call (sigreturn or rt_sigreturn, see
regcache_cooked_read_unsigned (regcache, I386_ESP_REGNUM, &sp);
if (syscall == SYS_rt_sigreturn)
- addr = read_memory_integer (sp + 8, 4) + 20;
+ addr = read_memory_integer (sp + 8, 4, byte_order) + 20;
else
addr = sp;
static CORE_ADDR
i386_linux_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc;
CORE_ADDR sp;
gdb_byte buf[4];
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
pc = i386_linux_sigtramp_start (this_frame);
if (pc)
pointer to the user context is passed as the third argument
to the signal handler. */
read_memory (sp + 8, buf, 4);
- ucontext_addr = extract_unsigned_integer (buf, 4);
+ ucontext_addr = extract_unsigned_integer (buf, 4, byte_order);
return ucontext_addr + I386_LINUX_UCONTEXT_SIGCONTEXT_OFFSET;
}
static CORE_ADDR
i386nto_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[4];
CORE_ADDR ptrctx;
/* We store __ucontext_t addr in EDI register. */
get_frame_register (this_frame, I386_EDI_REGNUM, buf);
- ptrctx = extract_unsigned_integer (buf, 4);
+ ptrctx = extract_unsigned_integer (buf, 4, byte_order);
ptrctx += 24 /* Context pointer is at this offset. */;
return ptrctx;
CORE_ADDR from, CORE_ADDR to,
struct regcache *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* The offset we applied to the instruction's address.
This could well be negative (when viewed as a signed 32-bit
value), but ULONGEST won't reflect that, so take care when
const ULONGEST retaddr_len = 4;
regcache_cooked_read_unsigned (regs, I386_ESP_REGNUM, &esp);
- retaddr = read_memory_unsigned_integer (esp, retaddr_len);
+ retaddr = read_memory_unsigned_integer (esp, byte_order, retaddr_len);
retaddr = (retaddr - insn_offset) & 0xffffffffUL;
- write_memory_unsigned_integer (esp, retaddr_len, retaddr);
+ write_memory_unsigned_integer (esp, retaddr_len, byte_order, retaddr);
if (debug_displaced)
fprintf_unfiltered (gdb_stdlog,
target. Otherwise, return PC. */
static CORE_ADDR
-i386_follow_jump (CORE_ADDR pc)
+i386_follow_jump (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte op;
long delta = 0;
int data16 = 0;
if (op == 0x66)
{
data16 = 1;
- op = read_memory_unsigned_integer (pc + 1, 1);
+ op = read_memory_unsigned_integer (pc + 1, 1, byte_order);
}
switch (op)
/* Relative jump: if data16 == 0, disp32, else disp16. */
if (data16)
{
- delta = read_memory_integer (pc + 2, 2);
+ delta = read_memory_integer (pc + 2, 2, byte_order);
/* Include the size of the jmp instruction (including the
0x66 prefix). */
}
else
{
- delta = read_memory_integer (pc + 1, 4);
+ delta = read_memory_integer (pc + 1, 4, byte_order);
/* Include the size of the jmp instruction. */
delta += 5;
break;
case 0xeb:
/* Relative jump, disp8 (ignore data16). */
- delta = read_memory_integer (pc + data16 + 1, 1);
+ delta = read_memory_integer (pc + data16 + 1, 1, byte_order);
delta += data16 + 2;
break;
whichever is smaller. If we don't recognize the code, return PC. */
static CORE_ADDR
-i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
+i386_analyze_frame_setup (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR limit,
struct i386_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct i386_insn *insn;
gdb_byte op;
int skip = 0;
switch (op)
{
case 0x8b:
- if (read_memory_unsigned_integer (pc + skip + 1, 1) != 0xec)
+ if (read_memory_unsigned_integer (pc + skip + 1, 1, byte_order)
+ != 0xec)
return pc;
break;
case 0x89:
- if (read_memory_unsigned_integer (pc + skip + 1, 1) != 0xe5)
+ if (read_memory_unsigned_integer (pc + skip + 1, 1, byte_order)
+ != 0xe5)
return pc;
break;
default:
if (op == 0x83)
{
/* `subl' with 8-bit immediate. */
- if (read_memory_unsigned_integer (pc + 1, 1) != 0xec)
+ if (read_memory_unsigned_integer (pc + 1, 1, byte_order) != 0xec)
/* Some instruction starting with 0x83 other than `subl'. */
return pc;
/* `subl' with signed 8-bit immediate (though it wouldn't
make sense to be negative). */
- cache->locals = read_memory_integer (pc + 2, 1);
+ cache->locals = read_memory_integer (pc + 2, 1, byte_order);
return pc + 3;
}
else if (op == 0x81)
{
/* Maybe it is `subl' with a 32-bit immediate. */
- if (read_memory_unsigned_integer (pc + 1, 1) != 0xec)
+ if (read_memory_unsigned_integer (pc + 1, 1, byte_order) != 0xec)
/* Some instruction starting with 0x81 other than `subl'. */
return pc;
/* It is `subl' with a 32-bit immediate. */
- cache->locals = read_memory_integer (pc + 2, 4);
+ cache->locals = read_memory_integer (pc + 2, 4, byte_order);
return pc + 6;
}
else
}
else if (op == 0xc8) /* enter */
{
- cache->locals = read_memory_unsigned_integer (pc + 1, 2);
+ cache->locals = read_memory_unsigned_integer (pc + 1, 2, byte_order);
return pc + 4;
}
instruction will be a branch back to the start. */
static CORE_ADDR
-i386_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+i386_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR current_pc,
struct i386_frame_cache *cache)
{
pc = i386_skip_noop (pc);
- pc = i386_follow_jump (pc);
+ pc = i386_follow_jump (gdbarch, pc);
pc = i386_analyze_struct_return (pc, current_pc, cache);
pc = i386_skip_probe (pc);
pc = i386_analyze_stack_align (pc, current_pc, cache);
- pc = i386_analyze_frame_setup (pc, current_pc, cache);
+ pc = i386_analyze_frame_setup (gdbarch, pc, current_pc, cache);
return i386_analyze_register_saves (pc, current_pc, cache);
}
static CORE_ADDR
i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
static gdb_byte pic_pat[6] =
{
0xe8, 0, 0, 0, 0, /* call 0x0 */
int i;
cache.locals = -1;
- pc = i386_analyze_prologue (start_pc, 0xffffffff, &cache);
+ pc = i386_analyze_prologue (gdbarch, start_pc, 0xffffffff, &cache);
if (cache.locals < 0)
return start_pc;
if (op == 0x89) /* movl %ebx, x(%ebp) */
{
- op = read_memory_unsigned_integer (pc + delta + 1, 1);
+ op = read_memory_unsigned_integer (pc + delta + 1, 1, byte_order);
if (op == 0x5d) /* One byte offset from %ebp. */
delta += 3;
/* addl y,%ebx */
if (delta > 0 && op == 0x81
- && read_memory_unsigned_integer (pc + delta + 1, 1) == 0xc3)
+ && read_memory_unsigned_integer (pc + delta + 1, 1, byte_order)
+ == 0xc3)
{
pc += delta + 6;
}
/* If the function starts with a branch (to startup code at the end)
the last instruction should bring us back to the first
instruction of the real code. */
- if (i386_follow_jump (start_pc) != start_pc)
- pc = i386_follow_jump (pc);
+ if (i386_follow_jump (gdbarch, start_pc) != start_pc)
+ pc = i386_follow_jump (gdbarch, pc);
return pc;
}
CORE_ADDR
i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte op;
target_read_memory (pc, &op, 1);
/* Make sure address is computed correctly as a 32bit
integer even if CORE_ADDR is 64 bit wide. */
struct minimal_symbol *s;
- CORE_ADDR call_dest = pc + 5 + extract_signed_integer (buf, 4);
+ CORE_ADDR call_dest;
+ call_dest = pc + 5 + extract_signed_integer (buf, 4, byte_order);
call_dest = call_dest & 0xffffffffU;
s = lookup_minimal_symbol_by_pc (call_dest);
if (s != NULL
static struct i386_frame_cache *
i386_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct i386_frame_cache *cache;
gdb_byte buf[4];
int i;
in progress when the signal occurred. */
get_frame_register (this_frame, I386_EBP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 4);
+ cache->base = extract_unsigned_integer (buf, 4, byte_order);
if (cache->base == 0)
return cache;
cache->pc = get_frame_func (this_frame);
if (cache->pc != 0)
- i386_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+ i386_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+ cache);
if (cache->saved_sp_reg != -1)
{
/* Saved stack pointer has been saved. */
get_frame_register (this_frame, cache->saved_sp_reg, buf);
- cache->saved_sp = extract_unsigned_integer(buf, 4);
+ cache->saved_sp = extract_unsigned_integer (buf, 4, byte_order);
}
if (cache->locals < 0)
else
{
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset;
+ cache->base = extract_unsigned_integer (buf, 4, byte_order)
+ + cache->sp_offset;
}
}
static struct i386_frame_cache *
i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct i386_frame_cache *cache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
CORE_ADDR addr;
gdb_byte buf[4];
cache = i386_alloc_frame_cache ();
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 4) - 4;
+ cache->base = extract_unsigned_integer (buf, 4, byte_order) - 4;
addr = tdep->sigcontext_addr (this_frame);
if (tdep->sc_reg_offset)
gdb_byte buf[4];
CORE_ADDR sp, jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int jb_pc_offset = gdbarch_tdep (gdbarch)->jb_pc_offset;
/* If JB_PC_OFFSET is -1, we have no way to find out where the
return 0;
get_frame_register (frame, I386_ESP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
if (target_read_memory (sp + 4, buf, 4))
return 0;
- jb_addr = extract_unsigned_integer (buf, 4);
+ jb_addr = extract_unsigned_integer (buf, 4, byte_order);
if (target_read_memory (jb_addr + jb_pc_offset, buf, 4))
return 0;
- *pc = extract_unsigned_integer (buf, 4);
+ *pc = extract_unsigned_integer (buf, 4, byte_order);
return 1;
}
\f
struct value **args, CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
int i;
int write_pass;
if (write_pass)
{
/* Push value address. */
- store_unsigned_integer (buf, 4, struct_addr);
+ store_unsigned_integer (buf, 4, byte_order, struct_addr);
write_memory (sp, buf, 4);
args_space_used += 4;
}
/* Store return address. */
sp -= 4;
- store_unsigned_integer (buf, 4, bp_addr);
+ store_unsigned_integer (buf, 4, byte_order, bp_addr);
write_memory (sp, buf, 4);
/* Finally, update the stack pointer... */
- store_unsigned_integer (buf, 4, sp);
+ store_unsigned_integer (buf, 4, byte_order, sp);
regcache_cooked_write (regcache, I386_ESP_REGNUM, buf);
/* ...and fake a frame pointer. */
/* Stuff for WIN32 PE style DLL's but is pretty generic really. */
CORE_ADDR
-i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name)
+i386_pe_skip_trampoline_code (struct frame_info *frame,
+ CORE_ADDR pc, char *name)
{
- if (pc && read_memory_unsigned_integer (pc, 2) == 0x25ff) /* jmp *(dest) */
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
+ /* jmp *(dest) */
+ if (pc && read_memory_unsigned_integer (pc, 2, byte_order) == 0x25ff)
{
- unsigned long indirect = read_memory_unsigned_integer (pc + 2, 4);
+ unsigned long indirect =
+ read_memory_unsigned_integer (pc + 2, 4, byte_order);
struct minimal_symbol *indsym =
indirect ? lookup_minimal_symbol_by_pc (indirect) : 0;
char *symname = indsym ? SYMBOL_LINKAGE_NAME (indsym) : 0;
{
if (strncmp (symname, "__imp_", 6) == 0
|| strncmp (symname, "_imp_", 5) == 0)
- return name ? 1 : read_memory_unsigned_integer (indirect, 4);
+ return name ? 1 :
+ read_memory_unsigned_integer (indirect, 4, byte_order);
}
}
return 0; /* Not a trampoline. */
static CORE_ADDR
i386_svr4_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
CORE_ADDR sp;
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
- return read_memory_unsigned_integer (sp + 8, 4);
+ return read_memory_unsigned_integer (sp + 8, 4, byte_order);
}
\f
i386_fetch_pointer_argument (struct frame_info *frame, int argi,
struct type *type)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp = get_frame_register_unsigned (frame, I386_ESP_REGNUM);
- return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4);
+ return read_memory_unsigned_integer (sp + (4 * (argi + 1)), 4, byte_order);
}
static void
#define I386_MAX_INSN_LEN (16)
/* Functions exported from i386-tdep.c. */
-extern CORE_ADDR i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name);
+extern CORE_ADDR i386_pe_skip_trampoline_code (struct frame_info *frame,
+ CORE_ADDR pc, char *name);
extern CORE_ADDR i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc);
/* Return whether the THIS_FRAME corresponds to a sigtramp routine. */
static CORE_ADDR
i386bsd_sigcontext_addr (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
CORE_ADDR sp;
get_frame_register (this_frame, I386_ESP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
- return read_memory_unsigned_integer (sp + 8, 4);
+ return read_memory_unsigned_integer (sp + 8, 4, byte_order);
}
\f
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp = get_frame_register_unsigned (this_frame, I386_ESP_REGNUM);
CORE_ADDR base;
int *reg_offset;
num_regs = ARRAY_SIZE (i386nbsd_sc_reg_offset);
/* Read in the sigcontext address */
- base = read_memory_unsigned_integer (sp + 8, 4);
+ base = read_memory_unsigned_integer (sp + 8, 4, byte_order);
}
else
{
num_regs = ARRAY_SIZE (i386nbsd_mc_reg_offset);
/* Read in the ucontext address */
- base = read_memory_unsigned_integer (sp + 8, 4);
+ base = read_memory_unsigned_integer (sp + 8, 4, byte_order);
/* offsetof(ucontext_t, uc_mcontext) == 36 */
base += 36;
}
static int
i386obsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct switchframe sf;
/* The following is true for OpenBSD 3.6:
{
/* No, the pcb must have been last updated by savectx(). */
pcb->pcb_esp = pcb->pcb_ebp;
- pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4);
- sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4);
+ pcb->pcb_ebp = read_memory_integer(pcb->pcb_esp, 4, byte_order);
+ sf.sf_eip = read_memory_integer(pcb->pcb_esp + 4, 4, byte_order);
regcache_raw_supply (regcache, I386_EIP_REGNUM, &sf.sf_eip);
}
i386obsd_supply_uthread (struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp_addr = addr + I386OBSD_UTHREAD_ESP_OFFSET;
CORE_ADDR sp = 0;
gdb_byte buf[4];
int offset;
/* Fetch stack pointer from thread structure. */
- sp = read_memory_unsigned_integer (sp_addr, 4);
+ sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
/* Adjust the stack pointer such that it looks as if we just
returned from _thread_machdep_switch. */
offset = i386obsd_uthread_reg_offset[I386_EIP_REGNUM] + 4;
- store_unsigned_integer (buf, 4, sp + offset);
+ store_unsigned_integer (buf, 4, byte_order, sp + offset);
regcache_raw_supply (regcache, I386_ESP_REGNUM, buf);
}
/* Fetch stack pointer from thread structure (if we didn't
do so already). */
if (sp == 0)
- sp = read_memory_unsigned_integer (sp_addr, 4);
+ sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
/* Read the saved register from the stack frame. */
read_memory (sp + i386obsd_uthread_reg_offset[i], buf, 4);
i386obsd_collect_uthread (const struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp_addr = addr + I386OBSD_UTHREAD_ESP_OFFSET;
CORE_ADDR sp = 0;
gdb_byte buf[4];
stored into the thread structure. */
offset = i386obsd_uthread_reg_offset[I386_EIP_REGNUM] + 4;
regcache_raw_collect (regcache, I386_ESP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4) - offset;
+ sp = extract_unsigned_integer (buf, 4, byte_order) - offset;
/* Store the stack pointer. */
- write_memory_unsigned_integer (sp_addr, 4, sp);
+ write_memory_unsigned_integer (sp_addr, 4, byte_order, sp);
/* The stack pointer was (potentially) modified. Make sure we
build a proper stack frame. */
/* Fetch stack pointer from thread structure (if we didn't
calculate it already). */
if (sp == 0)
- sp = read_memory_unsigned_integer (sp_addr, 4);
+ sp = read_memory_unsigned_integer (sp_addr, 4, byte_order);
/* Write the register into the stack frame. */
regcache_raw_collect (regcache, i, buf);
static struct trad_frame_cache *
i386obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct trad_frame_cache *cache;
CORE_ADDR func, sp, addr;
ULONGEST cs;
/* Read %cs from trap frame. */
addr += i386obsd_tf_reg_offset[I386_CS_REGNUM];
- cs = read_memory_unsigned_integer (addr, 4);
+ cs = read_memory_unsigned_integer (addr, 4, byte_order);
if ((cs & I386_SEL_RPL) == I386_SEL_UPL)
{
/* Trap from user space; terminate backtrace. */
void
i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const gdb_byte *regs = fsave;
int i;
{
gdb_byte buf[4];
- store_unsigned_integer (buf, 4, 0x1f80);
+ store_unsigned_integer (buf, 4, byte_order, 0x1f80);
regcache_raw_supply (regcache, I387_MXCSR_REGNUM (tdep), buf);
}
}
sigcontext structure. */
static CORE_ADDR
-ia64_linux_sigcontext_register_address (CORE_ADDR sp, int regno)
+ia64_linux_sigcontext_register_address (struct gdbarch *gdbarch,
+ CORE_ADDR sp, int regno)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[8];
CORE_ADDR sigcontext_addr = 0;
/* The address of the sigcontext area is found at offset 16 in the sigframe. */
read_memory (sp + 16, buf, 8);
- sigcontext_addr = extract_unsigned_integer (buf, 8);
+ sigcontext_addr = extract_unsigned_integer (buf, 8, byte_order);
if (IA64_GR0_REGNUM <= regno && regno <= IA64_GR31_REGNUM)
return sigcontext_addr + 200 + 8 * (regno - IA64_GR0_REGNUM);
static gdbarch_breakpoint_from_pc_ftype ia64_breakpoint_from_pc;
static gdbarch_skip_prologue_ftype ia64_skip_prologue;
static struct type *is_float_or_hfa_type (struct type *t);
-static CORE_ADDR ia64_find_global_pointer (CORE_ADDR faddr);
+static CORE_ADDR ia64_find_global_pointer (struct gdbarch *gdbarch,
+ CORE_ADDR faddr);
#define NUM_IA64_RAW_REGS 462
ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
{
#ifdef HAVE_LIBUNWIND_IA64_H
if ((cfm & 0x7f) > regnum - V32_REGNUM)
{
ULONGEST reg_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
- reg = read_memory_integer ((CORE_ADDR)reg_addr, 8);
- store_unsigned_integer (buf, register_size (gdbarch, regnum), reg);
+ reg = read_memory_integer ((CORE_ADDR)reg_addr, 8, byte_order);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, reg);
}
else
- store_unsigned_integer (buf, register_size (gdbarch, regnum), 0);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, 0);
}
}
else if (IA64_NAT0_REGNUM <= regnum && regnum <= IA64_NAT31_REGNUM)
ULONGEST unat;
regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
unatN_val = (unat & (1LL << (regnum - IA64_NAT0_REGNUM))) != 0;
- store_unsigned_integer (buf, register_size (gdbarch, regnum), unatN_val);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, unatN_val);
}
else if (IA64_NAT32_REGNUM <= regnum && regnum <= IA64_NAT127_REGNUM)
{
if (nat_addr >= bsp)
regcache_cooked_read_unsigned (regcache, IA64_RNAT_REGNUM, &nat_collection);
else
- nat_collection = read_memory_integer (nat_addr, 8);
+ nat_collection = read_memory_integer (nat_addr, 8, byte_order);
nat_bit = (gr_addr >> 3) & 0x3f;
natN_val = (nat_collection >> nat_bit) & 1;
}
- store_unsigned_integer (buf, register_size (gdbarch, regnum), natN_val);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, natN_val);
}
else if (regnum == VBOF_REGNUM)
{
/* The bsp points at the end of the register frame so we
subtract the size of frame from it to get beginning of frame. */
vbsp = rse_address_add (bsp, -(cfm & 0x7f));
- store_unsigned_integer (buf, register_size (gdbarch, regnum), vbsp);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, vbsp);
}
else if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
{
+ ((regnum - VP16_REGNUM) + rrb_pr) % 48;
}
prN_val = (pr & (1LL << (regnum - VP0_REGNUM))) != 0;
- store_unsigned_integer (buf, register_size (gdbarch, regnum), prN_val);
+ store_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order, prN_val);
}
else
memset (buf, 0, register_size (gdbarch, regnum));
ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
if (regnum >= V32_REGNUM && regnum <= V127_REGNUM)
{
ULONGEST bsp;
{
ULONGEST unatN_val, unat, unatN_mask;
regcache_cooked_read_unsigned (regcache, IA64_UNAT_REGNUM, &unat);
- unatN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
+ unatN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order);
unatN_mask = (1LL << (regnum - IA64_NAT0_REGNUM));
if (unatN_val == 0)
unat &= ~unatN_mask;
if ((cfm & 0x7f) > regnum - V32_REGNUM)
gr_addr = rse_address_add (bsp, (regnum - V32_REGNUM));
- natN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
+ natN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order);
if (gr_addr != 0 && (natN_val == 0 || natN_val == 1))
{
else
{
char nat_buf[8];
- nat_collection = read_memory_integer (nat_addr, 8);
+ nat_collection = read_memory_integer (nat_addr, 8, byte_order);
if (natN_val)
nat_collection |= natN_mask;
else
nat_collection &= ~natN_mask;
- store_unsigned_integer (nat_buf, register_size (gdbarch, regnum), nat_collection);
+ store_unsigned_integer (nat_buf, register_size (gdbarch, regnum),
+ byte_order, nat_collection);
write_memory (nat_addr, nat_buf, 8);
}
}
regnum = VP16_REGNUM
+ ((regnum - VP16_REGNUM) + rrb_pr) % 48;
}
- prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum));
+ prN_val = extract_unsigned_integer (buf, register_size (gdbarch, regnum),
+ byte_order);
prN_mask = (1LL << (regnum - VP0_REGNUM));
if (prN_val == 0)
pr &= ~prN_mask;
this'll be wrong. FIXME */
if (this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
get_frame_register (this_frame, sp_regnum, buf);
- saved_sp = extract_unsigned_integer (buf, 8);
+ saved_sp = extract_unsigned_integer (buf, 8, byte_order);
}
spill_addr = saved_sp
+ (rM == 12 ? 0 : mem_stack_frame_size)
if (!frameless && this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* Extract the size of the rotating portion of the stack
frame and the register rename base from the current
frame marker. */
cfm = 0;
if (cache->saved_regs[IA64_CFM_REGNUM] != 0)
{
- cfm = read_memory_integer (cache->saved_regs[IA64_CFM_REGNUM], 8);
+ cfm = read_memory_integer (cache->saved_regs[IA64_CFM_REGNUM],
+ 8, byte_order);
}
else if (cfm_reg != 0)
{
get_frame_register (this_frame, cfm_reg, buf);
- cfm = extract_unsigned_integer (buf, 8);
+ cfm = extract_unsigned_integer (buf, 8, byte_order);
}
cache->prev_cfm = cfm;
static struct ia64_frame_cache *
ia64_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct ia64_frame_cache *cache;
char buf[8];
CORE_ADDR cfm, sof, sol, bsp, psr;
*this_cache = cache;
get_frame_register (this_frame, sp_regnum, buf);
- cache->saved_sp = extract_unsigned_integer (buf, 8);
+ cache->saved_sp = extract_unsigned_integer (buf, 8, byte_order);
/* We always want the bsp to point to the end of frame.
This way, we can always get the beginning of frame (bof)
by subtracting frame size. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- cache->bsp = extract_unsigned_integer (buf, 8);
+ cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 8);
+ psr = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
- cfm = extract_unsigned_integer (buf, 8);
+ cfm = extract_unsigned_integer (buf, 8, byte_order);
cache->sof = (cfm & 0x7f);
cache->sol = (cfm >> 7) & 0x7f;
int regnum)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
char buf[8];
that frame by adding the size of output:
(sof (size of frame) - sol (size of locals)). */
val = ia64_frame_prev_register (this_frame, this_cache, IA64_CFM_REGNUM);
- prev_cfm = extract_unsigned_integer (value_contents_all (val), 8);
+ prev_cfm = extract_unsigned_integer (value_contents_all (val),
+ 8, byte_order);
bsp = rse_address_add (cache->bsp, -(cache->sof));
prev_bsp =
rse_address_add (bsp, (prev_cfm & 0x7f) - ((prev_cfm >> 7) & 0x7f));
the nat collection from rnat. Otherwise, we fetch the nat
collection from the computed address. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
if (nat_addr >= bsp)
{
get_frame_register (this_frame, IA64_RNAT_REGNUM, buf);
- nat_collection = extract_unsigned_integer (buf, 8);
+ nat_collection = extract_unsigned_integer (buf, 8, byte_order);
}
else
- nat_collection = read_memory_integer (nat_addr, 8);
+ nat_collection = read_memory_integer (nat_addr, 8, byte_order);
nat_bit = (gr_addr >> 3) & 0x3f;
natval = (nat_collection >> nat_bit) & 1;
}
if (addr != 0)
{
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
- pc = extract_unsigned_integer (buf, 8);
+ pc = extract_unsigned_integer (buf, 8, byte_order);
}
else if (cache->frameless)
{
get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
- pc = extract_unsigned_integer (buf, 8);
+ pc = extract_unsigned_integer (buf, 8, byte_order);
}
pc &= ~0xf;
return frame_unwind_got_constant (this_frame, regnum, pc);
CORE_ADDR addr = cache->saved_regs[IA64_VRAP_REGNUM];
get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 8);
+ psr = extract_unsigned_integer (buf, 8, byte_order);
if (addr != 0)
{
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
- pc = extract_unsigned_integer (buf, 8);
+ pc = extract_unsigned_integer (buf, 8, byte_order);
}
else if (cache->frameless)
{
get_frame_register (this_frame, IA64_BR0_REGNUM, buf);
- pc = extract_unsigned_integer (buf, 8);
+ pc = extract_unsigned_integer (buf, 8, byte_order);
}
psr &= ~(3LL << 41);
slot_num = pc & 0x3LL;
reg_val = ia64_frame_prev_register (this_frame, this_cache,
IA64_CFM_REGNUM);
prev_cfm = extract_unsigned_integer (value_contents_all (reg_val),
- 8);
+ 8, byte_order);
reg_val = ia64_frame_prev_register (this_frame, this_cache,
IA64_BSP_REGNUM);
prev_bsp = extract_unsigned_integer (value_contents_all (reg_val),
- 8);
+ 8, byte_order);
prev_bof = rse_address_add (prev_bsp, -(prev_cfm & 0x7f));
addr = rse_address_add (prev_bof, (regnum - IA64_GR32_REGNUM));
ia64_sigtramp_frame_init_saved_regs (struct frame_info *this_frame,
struct ia64_frame_cache *cache)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
if (tdep->sigcontext_register_address)
{
int regno;
cache->saved_regs[IA64_VRAP_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_IP_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_IP_REGNUM);
cache->saved_regs[IA64_CFM_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_CFM_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_CFM_REGNUM);
cache->saved_regs[IA64_PSR_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_PSR_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_PSR_REGNUM);
cache->saved_regs[IA64_BSP_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_BSP_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_BSP_REGNUM);
cache->saved_regs[IA64_RNAT_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_RNAT_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_RNAT_REGNUM);
cache->saved_regs[IA64_CCV_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_CCV_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_CCV_REGNUM);
cache->saved_regs[IA64_UNAT_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_UNAT_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_UNAT_REGNUM);
cache->saved_regs[IA64_FPSR_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_FPSR_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_FPSR_REGNUM);
cache->saved_regs[IA64_PFS_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_PFS_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_PFS_REGNUM);
cache->saved_regs[IA64_LC_REGNUM] =
- tdep->sigcontext_register_address (cache->base, IA64_LC_REGNUM);
+ tdep->sigcontext_register_address (gdbarch, cache->base, IA64_LC_REGNUM);
for (regno = IA64_GR1_REGNUM; regno <= IA64_GR31_REGNUM; regno++)
cache->saved_regs[regno] =
- tdep->sigcontext_register_address (cache->base, regno);
+ tdep->sigcontext_register_address (gdbarch, cache->base, regno);
for (regno = IA64_BR0_REGNUM; regno <= IA64_BR7_REGNUM; regno++)
cache->saved_regs[regno] =
- tdep->sigcontext_register_address (cache->base, regno);
+ tdep->sigcontext_register_address (gdbarch, cache->base, regno);
for (regno = IA64_FR2_REGNUM; regno <= IA64_FR31_REGNUM; regno++)
cache->saved_regs[regno] =
- tdep->sigcontext_register_address (cache->base, regno);
+ tdep->sigcontext_register_address (gdbarch, cache->base, regno);
}
}
static struct ia64_frame_cache *
ia64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct ia64_frame_cache *cache;
CORE_ADDR addr;
char buf[8];
get_frame_register (this_frame, sp_regnum, buf);
/* Note that frame size is hard-coded below. We cannot calculate it
via prologue examination. */
- cache->base = extract_unsigned_integer (buf, 8) + 16;
+ cache->base = extract_unsigned_integer (buf, 8, byte_order) + 16;
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- cache->bsp = extract_unsigned_integer (buf, 8);
+ cache->bsp = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
- cache->cfm = extract_unsigned_integer (buf, 8);
+ cache->cfm = extract_unsigned_integer (buf, 8, byte_order);
cache->sof = cache->cfm & 0x7f;
ia64_sigtramp_frame_init_saved_regs (this_frame, cache);
char buf[MAX_REGISTER_SIZE];
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct ia64_frame_cache *cache =
ia64_sigtramp_frame_cache (this_frame, this_cache);
if (addr != 0)
{
read_memory (addr, buf, register_size (gdbarch, IA64_IP_REGNUM));
- pc = extract_unsigned_integer (buf, 8);
+ pc = extract_unsigned_integer (buf, 8, byte_order);
}
pc &= ~0xf;
return frame_unwind_got_constant (this_frame, regnum, pc);
unw_word_t bsp, sof, sol, cfm, psr, ip;
struct frame_info *this_frame = arg;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
long new_sof, old_sof;
char buf[MAX_REGISTER_SIZE];
/* Libunwind expects to see the pc value which means the slot number
from the psr must be merged with the ip word address. */
get_frame_register (this_frame, IA64_IP_REGNUM, buf);
- ip = extract_unsigned_integer (buf, 8);
+ ip = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 8);
+ psr = extract_unsigned_integer (buf, 8, byte_order);
*val = ip | ((psr >> 41) & 0x3);
break;
frame so we must account for the fact that ptrace() will return a value
for bsp that points *after* the current register frame. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
- cfm = extract_unsigned_integer (buf, 8);
+ cfm = extract_unsigned_integer (buf, 8, byte_order);
sof = (cfm & 0x7f);
*val = ia64_rse_skip_regs (bsp, -sof);
break;
/* Libunwind wants bspstore to be after the current register frame.
This is what ptrace() and gdb treats as the regular bsp value. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- *val = extract_unsigned_integer (buf, 8);
+ *val = extract_unsigned_integer (buf, 8, byte_order);
break;
default:
/* For all other registers, just unwind the value directly. */
get_frame_register (this_frame, regnum, buf);
- *val = extract_unsigned_integer (buf, 8);
+ *val = extract_unsigned_integer (buf, 8, byte_order);
break;
}
unw_word_t bsp, sof, sol, cfm, psr, ip;
struct regcache *regcache = arg;
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
long new_sof, old_sof;
char buf[MAX_REGISTER_SIZE];
/* Libunwind expects to see the pc value which means the slot number
from the psr must be merged with the ip word address. */
regcache_cooked_read (regcache, IA64_IP_REGNUM, buf);
- ip = extract_unsigned_integer (buf, 8);
+ ip = extract_unsigned_integer (buf, 8, byte_order);
regcache_cooked_read (regcache, IA64_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 8);
+ psr = extract_unsigned_integer (buf, 8, byte_order);
*val = ip | ((psr >> 41) & 0x3);
break;
frame so we must account for the fact that ptrace() will return a value
for bsp that points *after* the current register frame. */
regcache_cooked_read (regcache, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
regcache_cooked_read (regcache, IA64_CFM_REGNUM, buf);
- cfm = extract_unsigned_integer (buf, 8);
+ cfm = extract_unsigned_integer (buf, 8, byte_order);
sof = (cfm & 0x7f);
*val = ia64_rse_skip_regs (bsp, -sof);
break;
/* Libunwind wants bspstore to be after the current register frame.
This is what ptrace() and gdb treats as the regular bsp value. */
regcache_cooked_read (regcache, IA64_BSP_REGNUM, buf);
- *val = extract_unsigned_integer (buf, 8);
+ *val = extract_unsigned_integer (buf, 8, byte_order);
break;
default:
/* For all other registers, just unwind the value directly. */
regcache_cooked_read (regcache, regnum, buf);
- *val = extract_unsigned_integer (buf, 8);
+ *val = extract_unsigned_integer (buf, 8, byte_order);
break;
}
dip->start_ip = p_text->p_vaddr + load_base;
dip->end_ip = dip->start_ip + p_text->p_memsz;
- dip->gp = ia64_find_global_pointer (ip);
+ dip->gp = ia64_find_global_pointer (get_objfile_arch (objfile), ip);
dip->format = UNW_INFO_FORMAT_REMOTE_TABLE;
dip->u.rti.name_ptr = (unw_word_t) bfd_get_filename (bfd);
dip->u.rti.segbase = segbase;
struct frame_id *this_id)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct frame_id id;
char buf[8];
CORE_ADDR bsp;
/* We must add the bsp as the special address for frame comparison
purposes. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
(*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
{
int reg = regnum;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct value *val;
if (VP0_REGNUM <= regnum && regnum <= VP63_REGNUM)
/* Fetch predicate register rename base from current frame
marker for this frame. */
get_frame_register (this_frame, IA64_CFM_REGNUM, buf);
- cfm = extract_unsigned_integer (buf, 8);
+ cfm = extract_unsigned_integer (buf, 8, byte_order);
rrb_pr = (cfm >> 32) & 0x3f;
/* Adjust the register number to account for register rotation. */
register will be if we pop the frame back which is why we might
have been called. We know that libunwind will pass us back the
beginning of the current frame so we should just add sof to it. */
- prev_bsp = extract_unsigned_integer (value_contents_all (val), 8);
+ prev_bsp = extract_unsigned_integer (value_contents_all (val),
+ 8, byte_order);
cfm_val = libunwind_frame_prev_register (this_frame, this_cache,
IA64_CFM_REGNUM);
- prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val), 8);
+ prev_cfm = extract_unsigned_integer (value_contents_all (cfm_val),
+ 8, byte_order);
prev_bsp = rse_address_add (prev_bsp, (prev_cfm & 0x7f));
return frame_unwind_got_constant (this_frame, regnum, prev_bsp);
struct frame_id *this_id)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[8];
CORE_ADDR bsp;
struct frame_id id;
/* We must add the bsp as the special address for frame comparison
purposes. */
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
/* For a sigtramp frame, we don't make the check for previous ip being 0. */
(*this_id) = frame_id_build_special (id.stack_addr, id.code_addr, bsp);
ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *this_frame,
void **this_cache, int regnum)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct value *prev_ip_val;
CORE_ADDR prev_ip;
method of getting previous registers. */
prev_ip_val = libunwind_frame_prev_register (this_frame, this_cache,
IA64_IP_REGNUM);
- prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val), 8);
+ prev_ip = extract_unsigned_integer (value_contents_all (prev_ip_val),
+ 8, byte_order);
if (prev_ip == 0)
{
d_un.d_ptr value is the global pointer. */
static CORE_ADDR
-ia64_find_global_pointer (CORE_ADDR faddr)
+ia64_find_global_pointer (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *faddr_sect;
faddr_sect = find_pc_section (faddr);
status = target_read_memory (addr, buf, sizeof (buf));
if (status != 0)
break;
- tag = extract_signed_integer (buf, sizeof (buf));
+ tag = extract_signed_integer (buf, sizeof (buf), byte_order);
if (tag == DT_PLTGOT)
{
status = target_read_memory (addr + 8, buf, sizeof (buf));
if (status != 0)
break;
- global_pointer = extract_unsigned_integer (buf, sizeof (buf));
+ global_pointer = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
/* The payoff... */
return global_pointer;
corresponding (canonical) function descriptor. Return 0 if
not found. */
static CORE_ADDR
-find_extant_func_descr (CORE_ADDR faddr)
+find_extant_func_descr (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *faddr_sect;
/* Return early if faddr is already a function descriptor. */
status = target_read_memory (addr, buf, sizeof (buf));
if (status != 0)
break;
- faddr2 = extract_signed_integer (buf, sizeof (buf));
+ faddr2 = extract_signed_integer (buf, sizeof (buf), byte_order);
if (faddr == faddr2)
return addr;
static CORE_ADDR
find_func_descr (struct regcache *regcache, CORE_ADDR faddr, CORE_ADDR *fdaptr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR fdesc;
- fdesc = find_extant_func_descr (faddr);
+ fdesc = find_extant_func_descr (gdbarch, faddr);
if (fdesc == 0)
{
fdesc = *fdaptr;
*fdaptr += 16;
- global_pointer = ia64_find_global_pointer (faddr);
+ global_pointer = ia64_find_global_pointer (gdbarch, faddr);
if (global_pointer == 0)
regcache_cooked_read_unsigned (regcache,
IA64_GR1_REGNUM, &global_pointer);
- store_unsigned_integer (buf, 8, faddr);
- store_unsigned_integer (buf + 8, 8, global_pointer);
+ store_unsigned_integer (buf, 8, byte_order, faddr);
+ store_unsigned_integer (buf + 8, 8, byte_order, global_pointer);
write_memory (fdesc, buf, 16);
}
ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
struct target_ops *targ)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *s;
s = find_pc_section (addr);
/* check if ADDR points to a function descriptor. */
if (s && strcmp (s->the_bfd_section->name, ".opd") == 0)
- return read_memory_unsigned_integer (addr, 8);
+ return read_memory_unsigned_integer (addr, 8, byte_order);
/* Normally, functions live inside a section that is executable.
So, if ADDR points to a non-executable section, then treat it
the target address itself points to a section that is executable. */
if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
{
- CORE_ADDR pc = read_memory_unsigned_integer (addr, 8);
+ CORE_ADDR pc = read_memory_unsigned_integer (addr, 8, byte_order);
struct obj_section *pc_section = find_pc_section (pc);
if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
minsym = lookup_minimal_symbol_by_pc (addr);
if (minsym && is_vtable_name (SYMBOL_LINKAGE_NAME (minsym)))
- return read_memory_unsigned_integer (addr, 8);
+ return read_memory_unsigned_integer (addr, 8, byte_order);
}
return addr;
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argno;
struct value *arg;
struct type *type;
&& TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_FUNC)
{
char val_buf[8];
- ULONGEST faddr = extract_unsigned_integer (value_contents (arg), 8);
- store_unsigned_integer (val_buf, 8,
+ ULONGEST faddr = extract_unsigned_integer (value_contents (arg),
+ 8, byte_order);
+ store_unsigned_integer (val_buf, 8, byte_order,
find_func_descr (regcache, faddr,
&funcdescaddr));
if (slotnum < rseslots)
regcache_cooked_write_unsigned (regcache, IA64_GR8_REGNUM, (ULONGEST)struct_addr);
}
- global_pointer = ia64_find_global_pointer (func_addr);
+ global_pointer = ia64_find_global_pointer (gdbarch, func_addr);
if (global_pointer != 0)
regcache_cooked_write_unsigned (regcache, IA64_GR1_REGNUM, global_pointer);
static struct frame_id
ia64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[8];
CORE_ADDR sp, bsp;
get_frame_register (this_frame, sp_regnum, buf);
- sp = extract_unsigned_integer (buf, 8);
+ sp = extract_unsigned_integer (buf, 8, byte_order);
get_frame_register (this_frame, IA64_BSP_REGNUM, buf);
- bsp = extract_unsigned_integer (buf, 8);
+ bsp = extract_unsigned_integer (buf, 8, byte_order);
if (gdbarch_debug >= 1)
fprintf_unfiltered (gdb_stdlog,
static CORE_ADDR
ia64_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[8];
CORE_ADDR ip, psr, pc;
frame_unwind_register (next_frame, IA64_IP_REGNUM, buf);
- ip = extract_unsigned_integer (buf, 8);
+ ip = extract_unsigned_integer (buf, 8, byte_order);
frame_unwind_register (next_frame, IA64_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 8);
+ psr = extract_unsigned_integer (buf, 8, byte_order);
pc = (ip & ~0xf) | ((psr >> 41) & 3);
return pc;
struct gdbarch_tdep
{
- CORE_ADDR (*sigcontext_register_address) (CORE_ADDR, int);
+ CORE_ADDR (*sigcontext_register_address) (struct gdbarch *, CORE_ADDR, int);
int (*pc_in_sigtramp) (CORE_ADDR);
/* ISA-specific data types. */
iq2000_pointer_to_address (struct gdbarch *gdbarch,
struct type * type, const gdb_byte * buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
- CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ CORE_ADDR addr
+ = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
if (target == TYPE_CODE_FUNC
|| target == TYPE_CODE_METHOD
iq2000_address_to_pointer (struct gdbarch *gdbarch,
struct type *type, gdb_byte *buf, CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
addr = insn_ptr_from_addr (addr);
- store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
/* Real register methods: */
Returns the address of the first instruction after the prologue. */
static CORE_ADDR
-iq2000_scan_prologue (CORE_ADDR scan_start,
+iq2000_scan_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR scan_start,
CORE_ADDR scan_end,
struct frame_info *fi,
struct iq2000_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct symtab_and_line sal;
CORE_ADDR pc;
CORE_ADDR loop_end;
for (pc = scan_start; pc < loop_end; pc += 4)
{
- LONGEST insn = read_memory_unsigned_integer (pc, 4);
+ LONGEST insn = read_memory_unsigned_integer (pc, 4, byte_order);
/* Skip any instructions writing to (sp) or decrementing the
SP. */
if ((insn & 0xffe00000) == 0xac200000)
/* No useable line symbol. Use prologue parsing method. */
iq2000_init_frame_cache (&cache);
- return iq2000_scan_prologue (func_addr, func_end, NULL, &cache);
+ return iq2000_scan_prologue (gdbarch, func_addr, func_end, NULL, &cache);
}
/* No function symbol -- just return the PC. */
static struct iq2000_frame_cache *
iq2000_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct iq2000_frame_cache *cache;
CORE_ADDR current_pc;
int i;
current_pc = get_frame_pc (this_frame);
find_pc_partial_function (current_pc, NULL, &cache->pc, NULL);
if (cache->pc != 0)
- iq2000_scan_prologue (cache->pc, current_pc, this_frame, cache);
+ iq2000_scan_prologue (gdbarch, cache->pc, current_pc, this_frame, cache);
if (!cache->using_fp)
cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
iq2000_extract_return_value (struct type *type, struct regcache *regcache,
void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* If the function's return value is 8 bytes or less, it is
returned in a register, and if larger than 8 bytes, it is
returned in a stack location which is pointed to by the same
/* By using store_unsigned_integer we avoid having to
do anything special for small big-endian values. */
regcache_cooked_read_unsigned (regcache, regno++, &tmp);
- store_unsigned_integer (valbuf, size, tmp);
+ store_unsigned_integer (valbuf, size, byte_order, tmp);
len -= size;
valbuf = ((char *) valbuf) + size;
}
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const bfd_byte *val;
bfd_byte buf[4];
struct type *type;
regcache_cooked_write_unsigned (regcache, argreg++, struct_ptr);
else
{
- store_unsigned_integer (buf, 4, struct_ptr);
+ store_unsigned_integer (buf, 4, byte_order, struct_ptr);
write_memory (sp + stackspace, buf, 4);
stackspace += 4;
}
greg_t *regp = &(*gregsetp)[0];
gdb_byte buf[MAX_REGISTER_SIZE];
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Under Irix6, if GDB is built with N32 ABI and is debugging an O32
executable, we have to sign extend the registers to 64 bits before
{
size = register_size (gdbarch, regi);
regcache_raw_collect (regcache, regi, buf);
- *(regp + regi) = extract_signed_integer (buf, size);
+ *(regp + regi) = extract_signed_integer (buf, size, byte_order);
}
if ((regno == -1) || (regno == gdbarch_pc_regnum (gdbarch)))
regi = mips_regnum (gdbarch)->pc;
size = register_size (gdbarch, regi);
regcache_raw_collect (regcache, regi, buf);
- *(regp + CTX_EPC) = extract_signed_integer (buf, size);
+ *(regp + CTX_EPC) = extract_signed_integer (buf, size, byte_order);
}
if ((regno == -1) || (regno == mips_regnum (gdbarch)->cause))
regi = mips_regnum (gdbarch)->cause;
size = register_size (gdbarch, regi);
regcache_raw_collect (regcache, regi, buf);
- *(regp + CTX_CAUSE) = extract_signed_integer (buf, size);
+ *(regp + CTX_CAUSE) = extract_signed_integer (buf, size, byte_order);
}
if ((regno == -1) || (regno == mips_regnum (gdbarch)->hi))
regi = mips_regnum (gdbarch)->hi;
size = register_size (gdbarch, regi);
regcache_raw_collect (regcache, regi, buf);
- *(regp + CTX_MDHI) = extract_signed_integer (buf, size);
+ *(regp + CTX_MDHI) = extract_signed_integer (buf, size, byte_order);
}
if ((regno == -1) || (regno == mips_regnum (gdbarch)->lo))
regi = mips_regnum (gdbarch)->lo;
size = register_size (gdbarch, regi);
regcache_raw_collect (regcache, regi, buf);
- *(regp + CTX_MDLO) = extract_signed_integer (buf, size);
+ *(regp + CTX_MDLO) = extract_signed_integer (buf, size, byte_order);
}
}
if (TYPE_CODE (type) == TYPE_CODE_STRUCT
&& i > 2 && name[i - 1] == ']')
{
+ enum bfd_endian byte_order = gdbarch_byte_order (exp->gdbarch);
CORE_ADDR address;
long length, index;
struct type *el_type;
address = value_as_address (arg1);
address += get_java_object_header_size (exp->gdbarch);
read_memory (address, buf4, 4);
- length = (long) extract_signed_integer (buf4, 4);
+ length = (long) extract_signed_integer (buf4, 4, byte_order);
index = (long) value_as_long (arg2);
if (index >= length || index < 0)
error (_("array index (%ld) out of bounds (length: %ld)"),
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (value_type (val));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *type;
CORE_ADDR address;
int i;
i = 0;
read_memory (address + get_java_object_header_size (gdbarch), buf4, 4);
- length = (long) extract_signed_integer (buf4, 4);
+ length = (long) extract_signed_integer (buf4, 4, byte_order);
fprintf_filtered (stream, "{length: %ld", length);
if (el_type == NULL)
pulls a host sized pointer out of the target and
then extracts that as an address (while assuming
that the address is unsigned)! */
- element = extract_unsigned_integer (buf, sizeof (buf));
+ element = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
}
for (reps = 1; i + reps < length; reps++)
pulls a host sized pointer out of the target and
then extracts that as an address (while assuming
that the address is unsigned)! */
- next_element = extract_unsigned_integer (buf, sizeof (buf));
+ next_element = extract_unsigned_integer (buf, sizeof (buf),
+ byte_order);
if (next_element != element)
break;
}
/* Analyze a function's prologue. */
static CORE_ADDR
-lm32_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
+lm32_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR limit,
struct lm32_frame_cache *info)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long instruction;
/* Keep reading though instructions, until we come across an instruction
{
/* Read an instruction. */
- instruction = read_memory_integer (pc, 4);
+ instruction = read_memory_integer (pc, 4, byte_order);
if ((LM32_OPCODE (instruction) == OP_SW)
&& (LM32_REG0 (instruction) == SIM_LM32_SP_REGNUM))
limit_pc = pc + 100; /* Magic. */
frame_info.saved_regs = saved_regs;
- return lm32_analyze_prologue (pc, limit_pc, &frame_info);
+ return lm32_analyze_prologue (gdbarch, pc, limit_pc, &frame_info);
}
/* Create a breakpoint instruction. */
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int first_arg_reg = SIM_LM32_R1_REGNUM;
int num_arg_regs = 8;
int i;
contents = (gdb_byte *) value_contents (arg);
len = TYPE_LENGTH (arg_type);
- val = extract_unsigned_integer (contents, len);
+ val = extract_unsigned_integer (contents, len, byte_order);
/* First num_arg_regs parameters are passed by registers,
and the rest are passed on the stack. */
lm32_extract_return_value (struct type *type, struct regcache *regcache,
gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int offset;
ULONGEST l;
CORE_ADDR return_buffer;
{
/* Return value is returned in a single register. */
regcache_cooked_read_unsigned (regcache, SIM_LM32_R1_REGNUM, &l);
- store_unsigned_integer (valbuf, TYPE_LENGTH (type), l);
+ store_unsigned_integer (valbuf, TYPE_LENGTH (type), byte_order, l);
}
else if ((TYPE_CODE (type) == TYPE_CODE_INT) && (TYPE_LENGTH (type) == 8))
{
lm32_store_return_value (struct type *type, struct regcache *regcache,
const gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
int len = TYPE_LENGTH (type);
if (len <= 4)
{
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
}
else if (len <= 8)
{
- val = extract_unsigned_integer (valbuf, 4);
+ val = extract_unsigned_integer (valbuf, 4, byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R1_REGNUM, val);
- val = extract_unsigned_integer (valbuf + 4, len - 4);
+ val = extract_unsigned_integer (valbuf + 4, len - 4, byte_order);
regcache_cooked_write_unsigned (regcache, SIM_LM32_R2_REGNUM, val);
}
else
info->pc = get_frame_func (this_frame);
current_pc = get_frame_pc (this_frame);
- lm32_analyze_prologue (info->pc, current_pc, info);
+ lm32_analyze_prologue (get_frame_arch (this_frame),
+ info->pc, current_pc, info);
/* Compute the frame's base, and the previous frame's SP. */
this_base = get_frame_register_unsigned (this_frame, SIM_LM32_SP_REGNUM);
CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long mach = gdbarch_bfd_arch_info (gdbarch)->mach;
CORE_ADDR cfa;
int i;
{
int ptr_len = TYPE_LENGTH (tdep->ptr_voyd);
sp -= ptr_len;
- write_memory_unsigned_integer (sp, ptr_len, struct_addr);
+ write_memory_unsigned_integer (sp, ptr_len, byte_order, struct_addr);
}
/* Push the arguments. */
sure it ends up in the least significant end of r1. (GDB
should avoid assuming endianness, even on uni-endian
processors.) */
- ULONGEST u = extract_unsigned_integer (arg_bits, arg_size);
+ ULONGEST u = extract_unsigned_integer (arg_bits, arg_size,
+ byte_order);
struct m32c_reg *reg = (mach == bfd_mach_m16c) ? tdep->r1 : tdep->r0;
regcache_cooked_write_unsigned (regcache, reg->num, u);
}
/* Push the return address. */
sp -= tdep->ret_addr_bytes;
- write_memory_unsigned_integer (sp, tdep->ret_addr_bytes, bp_addr);
+ write_memory_unsigned_integer (sp, tdep->ret_addr_bytes, byte_order,
+ bp_addr);
/* Update the stack pointer. */
regcache_cooked_write_unsigned (regcache, tdep->sp->num, sp);
const gdb_byte *writebuf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum return_value_convention conv;
ULONGEST valtype_len = TYPE_LENGTH (valtype);
{
ULONGEST u;
regcache_cooked_read_unsigned (regcache, tdep->r0->num, &u);
- store_unsigned_integer (readbuf, valtype_len, u);
+ store_unsigned_integer (readbuf, valtype_len, byte_order, u);
}
else
{
/* Anything that fits in r0 is returned there. */
if (valtype_len <= TYPE_LENGTH (tdep->r0->type))
{
- ULONGEST u = extract_unsigned_integer (writebuf, valtype_len);
+ ULONGEST u = extract_unsigned_integer (writebuf, valtype_len,
+ byte_order);
regcache_cooked_write_unsigned (regcache, tdep->r0->num, u);
}
else
static CORE_ADDR
m32c_skip_trampoline_code (struct frame_info *frame, CORE_ADDR stop_pc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* It would be nicer to simply look up the addresses of known
trampolines once, and then compare stop_pc with them. However,
m32c_jsri*16*. */
CORE_ADDR sp = get_frame_sp (get_current_frame ());
CORE_ADDR target
- = read_memory_unsigned_integer (sp + tdep->ret_addr_bytes, 2);
+ = read_memory_unsigned_integer (sp + tdep->ret_addr_bytes,
+ 2, byte_order);
/* What we have now is the address of a jump instruction.
What we need is the destination of that jump.
The opcode is 1 byte, and the destination is the next 3 bytes.
*/
- target = read_memory_unsigned_integer (target + 1, 3);
+ target = read_memory_unsigned_integer (target + 1, 3, byte_order);
return target;
}
}
m32c_m16c_address_to_pointer (struct gdbarch *gdbarch,
struct type *type, gdb_byte *buf, CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum type_code target_code;
gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
TYPE_CODE (type) == TYPE_CODE_REF);
addr = SYMBOL_VALUE_ADDRESS (tramp_msym);
}
- store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
m32c_m16c_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR ptr;
enum type_code target_code;
gdb_assert (TYPE_CODE (type) == TYPE_CODE_PTR ||
TYPE_CODE (type) == TYPE_CODE_REF);
- ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ ptr = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
target_code = TYPE_CODE (TYPE_TARGET_TYPE (type));
m32r_store_return_value (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR regval;
int len = TYPE_LENGTH (type);
- regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len);
+ regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
regcache_cooked_write_unsigned (regcache, RET1_REGNUM, regval);
if (len > 4)
{
- regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4, len - 4);
+ regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4,
+ len - 4, byte_order);
regcache_cooked_write_unsigned (regcache, RET1_REGNUM + 1, regval);
}
}
should be cached because this thrashing is getting nuts. */
static int
-decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit,
+decode_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start_pc, CORE_ADDR scan_limit,
CORE_ADDR *pl_endptr, unsigned long *framelength)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long framesize;
int insn;
int op1;
for (current_pc = start_pc; current_pc < scan_limit; current_pc += 2)
{
/* Check if current pc's location is readable. */
- if (!safe_read_memory_integer (current_pc, 2, &return_value))
+ if (!safe_read_memory_integer (current_pc, 2, byte_order, &return_value))
return -1;
- insn = read_memory_unsigned_integer (current_pc, 2);
+ insn = read_memory_unsigned_integer (current_pc, 2, byte_order);
if (insn == 0x0000)
break;
current_pc += 2; /* skip the immediate data */
/* Check if current pc's location is readable. */
- if (!safe_read_memory_integer (current_pc, 2, &return_value))
+ if (!safe_read_memory_integer (current_pc, 2, byte_order,
+ &return_value))
return -1;
if (insn == 0x8faf) /* add3 sp, sp, xxxx */
/* add 16 bit sign-extended offset */
{
framesize +=
- -((short) read_memory_unsigned_integer (current_pc, 2));
+ -((short) read_memory_unsigned_integer (current_pc,
+ 2, byte_order));
}
else
{
if (((insn >> 8) == 0xe4) /* ld24 r4, xxxxxx; sub sp, r4 */
- && safe_read_memory_integer (current_pc + 2, 2,
+ && safe_read_memory_integer (current_pc + 2,
+ 2, byte_order,
&return_value)
&& read_memory_unsigned_integer (current_pc + 2,
- 2) == 0x0f24)
+ 2, byte_order)
+ == 0x0f24)
/* subtract 24 bit sign-extended negative-offset */
{
- insn = read_memory_unsigned_integer (current_pc - 2, 4);
+ insn = read_memory_unsigned_integer (current_pc - 2,
+ 4, byte_order);
if (insn & 0x00800000) /* sign extend */
insn |= 0xff000000; /* negative */
else
static CORE_ADDR
m32r_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr, func_end;
struct symtab_and_line sal;
LONGEST return_value;
func_end = pc + DEFAULT_SEARCH_LIMIT;
/* If pc's location is not readable, just quit. */
- if (!safe_read_memory_integer (pc, 4, &return_value))
+ if (!safe_read_memory_integer (pc, 4, byte_order, &return_value))
return pc;
/* Find the end of prologue. */
- if (decode_prologue (pc, func_end, &sal.end, NULL) < 0)
+ if (decode_prologue (gdbarch, pc, func_end, &sal.end, NULL) < 0)
return pc;
return sal.end;
struct value **args, CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_offset, stack_alloc;
int argreg = ARG1_REGNUM;
int argnum;
if (len > 8
&& (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
{
- store_unsigned_integer (valbuf, 4, value_address (args[argnum]));
+ store_unsigned_integer (valbuf, 4, byte_order,
+ value_address (args[argnum]));
typecode = TYPE_CODE_PTR;
len = 4;
val = valbuf;
/* there's room in a register */
regval =
extract_unsigned_integer (val,
- register_size (gdbarch, argreg));
+ register_size (gdbarch, argreg),
+ byte_order);
regcache_cooked_write_unsigned (regcache, argreg++, regval);
}
m32r_extract_return_value (struct type *type, struct regcache *regcache,
void *dst)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
bfd_byte *valbuf = dst;
int len = TYPE_LENGTH (type);
ULONGEST tmp;
/* By using store_unsigned_integer we avoid having to do
anything special for small big-endian values. */
regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &tmp);
- store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), tmp);
+ store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
/* Ignore return values more than 8 bytes in size because the m32r
returns anything more than 8 bytes in the stack. */
if (len > 4)
{
regcache_cooked_read_unsigned (regcache, RET1_REGNUM + 1, &tmp);
- store_unsigned_integer (valbuf + len - 4, 4, tmp);
+ store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
}
}
struct regcache *regcache,
int regno, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* The PC is a pseudo reg only for 68HC12 with the memory bank
addressing mode. */
if (regno == M68HC12_HARD_PC_REGNUM)
pc += (page << 14);
pc += 0x1000000;
}
- store_unsigned_integer (buf, regsize, pc);
+ store_unsigned_integer (buf, regsize, byte_order, pc);
return;
}
struct regcache *regcache,
int regno, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* The PC is a pseudo reg only for 68HC12 with the memory bank
addressing mode. */
if (regno == M68HC12_HARD_PC_REGNUM)
CORE_ADDR pc;
memcpy (tmp, buf, regsize);
- pc = extract_unsigned_integer (tmp, regsize);
+ pc = extract_unsigned_integer (tmp, regsize, byte_order);
if (pc >= 0x1000000)
{
pc -= 0x1000000;
Returns a pointer to the sequence when it is recognized and
the optional value (constant/address) associated with it. */
static struct insn_sequence *
-m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR pc,
+m68hc11_analyze_instruction (struct gdbarch *gdbarch,
+ struct insn_sequence *seq, CORE_ADDR pc,
CORE_ADDR *val)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned char buffer[MAX_CODES];
unsigned bufsize;
unsigned j;
if (bufsize < j + 1)
{
buffer[bufsize] = read_memory_unsigned_integer (pc + bufsize,
- 1);
+ 1, byte_order);
bufsize++;
}
/* Continue while we match the opcode. */
}
else if ((buffer[j] & 0xfe) == 0xf0)
{
- v = read_memory_unsigned_integer (pc + j + 1, 1);
+ v = read_memory_unsigned_integer (pc + j + 1, 1, byte_order);
if (buffer[j] & 1)
v |= 0xff00;
}
else if (buffer[j] == 0xf2)
{
- v = read_memory_unsigned_integer (pc + j + 1, 2);
+ v = read_memory_unsigned_integer (pc + j + 1, 2, byte_order);
}
cur_val = v;
break;
struct insn_sequence *seq;
CORE_ADDR val;
- seq = m68hc11_analyze_instruction (seq_table, pc, &val);
+ seq = m68hc11_analyze_instruction (gdbarch, seq_table, pc, &val);
if (seq == 0)
break;
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argnum;
int first_stack_argnum;
struct type *type;
{
ULONGEST v;
- v = extract_unsigned_integer (value_contents (args[0]), len);
+ v = extract_unsigned_integer (value_contents (args[0]),
+ len, byte_order);
first_stack_argnum = 1;
regcache_cooked_write_unsigned (regcache, HARD_D_REGNUM, v);
/* Store return address. */
sp -= 2;
- store_unsigned_integer (buf, 2, bp_addr);
+ store_unsigned_integer (buf, 2, byte_order, bp_addr);
write_memory (sp, buf, 2);
/* Finally, update the stack pointer... */
CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
int i;
/* Store struct value address. */
if (struct_return)
{
- store_unsigned_integer (buf, 4, struct_addr);
+ store_unsigned_integer (buf, 4, byte_order, struct_addr);
regcache_cooked_write (regcache, tdep->struct_value_regnum, buf);
}
/* Store return address. */
sp -= 4;
- store_unsigned_integer (buf, 4, bp_addr);
+ store_unsigned_integer (buf, 4, byte_order, bp_addr);
write_memory (sp, buf, 4);
/* Finally, update the stack pointer... */
- store_unsigned_integer (buf, 4, sp);
+ store_unsigned_integer (buf, 4, byte_order, sp);
regcache_cooked_write (regcache, M68K_SP_REGNUM, buf);
/* ...and fake a frame pointer. */
Otherwise, return PC. */
static CORE_ADDR
-m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
+m68k_analyze_frame_setup (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR current_pc,
struct m68k_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int op;
if (pc >= current_pc)
return current_pc;
- op = read_memory_unsigned_integer (pc, 2);
+ op = read_memory_unsigned_integer (pc, 2, byte_order);
if (op == P_LINKW_FP || op == P_LINKL_FP || op == P_PEA_FP)
{
{
/* link.w %fp, #-N */
/* link.w %fp, #0; adda.l #-N, %sp */
- cache->locals = -read_memory_integer (pc + 2, 2);
+ cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
if (pc + 4 < current_pc && cache->locals == 0)
{
- op = read_memory_unsigned_integer (pc + 4, 2);
+ op = read_memory_unsigned_integer (pc + 4, 2, byte_order);
if (op == P_ADDAL_SP)
{
- cache->locals = read_memory_integer (pc + 6, 4);
+ cache->locals = read_memory_integer (pc + 6, 4, byte_order);
return pc + 10;
}
}
else if (op == P_LINKL_FP)
{
/* link.l %fp, #-N */
- cache->locals = -read_memory_integer (pc + 2, 4);
+ cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
return pc + 6;
}
else
if (pc + 2 < current_pc)
{
- op = read_memory_unsigned_integer (pc + 2, 2);
+ op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
if (op == P_MOVEAL_SP_FP)
{
cache->locals = (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
if (pc + 2 < current_pc)
{
- op = read_memory_unsigned_integer (pc + 2, 2);
+ op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
if ((op & 0170777) == P_SUBQW_SP || (op & 0170777) == P_SUBQL_SP)
{
cache->locals += (op & 07000) == 0 ? 8 : (op & 07000) >> 9;
{
/* adda.w #-N,%sp */
/* lea (-N,%sp),%sp */
- cache->locals = -read_memory_integer (pc + 2, 2);
+ cache->locals = -read_memory_integer (pc + 2, 2, byte_order);
return pc + 4;
}
else if (op == P_ADDAL_SP)
{
/* adda.l #-N,%sp */
- cache->locals = -read_memory_integer (pc + 2, 4);
+ cache->locals = -read_memory_integer (pc + 2, 4, byte_order);
return pc + 6;
}
CORE_ADDR current_pc,
struct m68k_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
if (cache->locals >= 0)
{
CORE_ADDR offset;
offset = -4 - cache->locals;
while (pc < current_pc)
{
- op = read_memory_unsigned_integer (pc, 2);
+ op = read_memory_unsigned_integer (pc, 2, byte_order);
if (op == P_FMOVEMX_SP
&& gdbarch_tdep (gdbarch)->fpregs_present)
{
/* fmovem.x REGS,-(%sp) */
- op = read_memory_unsigned_integer (pc + 2, 2);
+ op = read_memory_unsigned_integer (pc + 2, 2, byte_order);
if ((op & 0xff00) == 0xe000)
{
mask = op & 0xff;
else if (op == P_MOVEML_SP)
{
/* movem.l REGS,-(%sp) */
- mask = read_memory_unsigned_integer (pc + 2, 2);
+ mask = read_memory_unsigned_integer (pc + 2, 2, byte_order);
for (i = 0; i < 16; i++, mask >>= 1)
{
if (mask & 1)
m68k_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
CORE_ADDR current_pc, struct m68k_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int op;
- pc = m68k_analyze_frame_setup (pc, current_pc, cache);
+ pc = m68k_analyze_frame_setup (gdbarch, pc, current_pc, cache);
pc = m68k_analyze_register_saves (gdbarch, pc, current_pc, cache);
if (pc >= current_pc)
return current_pc;
/* Check for GOT setup. */
- op = read_memory_unsigned_integer (pc, 4);
+ op = read_memory_unsigned_integer (pc, 4, byte_order);
if (op == P_LEA_PC_A5)
{
/* lea (%pc,N),%a5 */
static struct m68k_frame_cache *
m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct m68k_frame_cache *cache;
gdb_byte buf[4];
int i;
in progress when the signal occurred. */
get_frame_register (this_frame, M68K_FP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 4);
+ cache->base = extract_unsigned_integer (buf, 4, byte_order);
if (cache->base == 0)
return cache;
functions this might work too. */
get_frame_register (this_frame, M68K_SP_REGNUM, buf);
- cache->base = extract_unsigned_integer (buf, 4) + cache->sp_offset;
+ cache->base = extract_unsigned_integer (buf, 4, byte_order)
+ + cache->sp_offset;
}
/* Now that we have the base address for the stack frame we can
gdb_byte *buf;
CORE_ADDR sp, jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
if (tdep->jb_pc < 0)
{
return 0;
jb_addr = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
- / TARGET_CHAR_BIT);
+ / TARGET_CHAR_BIT, byte_order);
if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf,
- gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT))
+ gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT),
+ byte_order)
return 0;
*pc = extract_unsigned_integer (buf, gdbarch_ptr_bit (gdbarch)
- / TARGET_CHAR_BIT);
+ / TARGET_CHAR_BIT, byte_order);
return 1;
}
\f
static int
m68k_linux_pc_in_sigtramp (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
gdb_byte buf[12];
unsigned long insn0, insn1, insn2;
if (!safe_frame_unwind_memory (this_frame, pc - 4, buf, sizeof (buf)))
return 0;
- insn1 = extract_unsigned_integer (buf + 4, 4);
- insn2 = extract_unsigned_integer (buf + 8, 4);
+ insn1 = extract_unsigned_integer (buf + 4, 4, byte_order);
+ insn2 = extract_unsigned_integer (buf + 8, 4, byte_order);
if (IS_SIGTRAMP (insn1, insn2))
return 1;
if (IS_RT_SIGTRAMP (insn1, insn2))
return 2;
- insn0 = extract_unsigned_integer (buf, 4);
+ insn0 = extract_unsigned_integer (buf, 4, byte_order);
if (IS_SIGTRAMP (insn0, insn1))
return 1;
if (IS_RT_SIGTRAMP (insn0, insn1))
static struct m68k_linux_sigtramp_info
m68k_linux_get_sigtramp_info (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
struct m68k_linux_sigtramp_info info;
sp = get_frame_register_unsigned (this_frame, M68K_SP_REGNUM);
/* Get sigcontext address, it is the third parameter on the stack. */
- info.sigcontext_addr = read_memory_unsigned_integer (sp + 8, 4);
+ info.sigcontext_addr = read_memory_unsigned_integer (sp + 8, 4, byte_order);
if (m68k_linux_pc_in_sigtramp (this_frame) == 2)
info.sc_reg_offset = m68k_linux_ucontext_reg_offset;
{
struct frame_id this_id;
struct trad_frame_cache *cache;
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (this_frame));
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct m68k_linux_sigtramp_info info;
gdb_byte buf[4];
int i;
trampoline. */
get_frame_register (this_frame, M68K_SP_REGNUM, buf);
/* See the end of m68k_push_dummy_call. */
- this_id = frame_id_build (extract_unsigned_integer (buf, 4) - 4 + 8,
- get_frame_pc (this_frame));
+ this_id = frame_id_build (extract_unsigned_integer (buf, 4, byte_order)
+ - 4 + 8, get_frame_pc (this_frame));
trad_frame_set_id (cache, this_id);
info = m68k_linux_get_sigtramp_info (this_frame);
/* Fetch the instruction at PC. */
static unsigned long
-m88k_fetch_instruction (CORE_ADDR pc)
+m88k_fetch_instruction (CORE_ADDR pc, enum bfd_endian byte_order)
{
- return read_memory_unsigned_integer (pc, 4);
+ return read_memory_unsigned_integer (pc, 4, byte_order);
}
/* Register information. */
prologue. */
static CORE_ADDR
-m88k_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
+m88k_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR limit,
struct m88k_frame_cache *cache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR end = limit;
/* Provide a dummy cache if necessary. */
while (pc < limit)
{
struct m88k_prologue_insn *pi = m88k_prologue_insn_table;
- unsigned long insn = m88k_fetch_instruction (pc);
+ unsigned long insn = m88k_fetch_instruction (pc, byte_order);
while ((insn & pi->mask) != pi->insn)
pi++;
return sal.end;
}
- return m88k_analyze_prologue (pc, pc + m88k_max_prologue_size, NULL);
+ return m88k_analyze_prologue (gdbarch, pc, pc + m88k_max_prologue_size,
+ NULL);
}
static struct m88k_frame_cache *
m88k_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct m88k_frame_cache *cache;
CORE_ADDR frame_sp;
cache->pc = get_frame_func (this_frame);
if (cache->pc != 0)
- m88k_analyze_prologue (cache->pc, get_frame_pc (this_frame), cache);
+ m88k_analyze_prologue (gdbarch, cache->pc, get_frame_pc (this_frame),
+ cache);
/* Calculate the stack pointer used in the prologue. */
if (cache->fp_offset != -1)
int cookednum,
void *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Read the raw register into a 64-bit buffer, and then return the
appropriate end of that buffer. */
int rawnum = mep_pseudo_to_raw[cookednum];
gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4);
regcache_raw_read (regcache, rawnum, buf64);
/* Slow, but legible. */
- store_unsigned_integer (buf, 4, extract_unsigned_integer (buf64, 8));
+ store_unsigned_integer (buf, 4, byte_order,
+ extract_unsigned_integer (buf64, 8, byte_order));
}
int cookednum,
const void *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int size = register_size (gdbarch, cookednum);
struct mep_csr_register *r
= &mep_csr_registers[cookednum - MEP_FIRST_CSR_REGNUM];
ULONGEST mixed_bits;
regcache_raw_read_unsigned (regcache, r->raw, &old_bits);
- new_bits = extract_unsigned_integer (buf, size);
+ new_bits = extract_unsigned_integer (buf, size, byte_order);
mixed_bits = ((r->writeable_bits & new_bits)
| (~r->writeable_bits & old_bits));
regcache_raw_write_unsigned (regcache, r->raw, mixed_bits);
int cookednum,
const void *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Expand the 32-bit value into a 64-bit value, and write that to
the pseudoregister. */
int rawnum = mep_pseudo_to_raw[cookednum];
gdb_assert (TYPE_LENGTH (register_type (gdbarch, rawnum)) == sizeof (buf64));
gdb_assert (TYPE_LENGTH (register_type (gdbarch, cookednum)) == 4);
/* Slow, but legible. */
- store_unsigned_integer (buf64, 8, extract_unsigned_integer (buf, 4));
+ store_unsigned_integer (buf64, 8, byte_order,
+ extract_unsigned_integer (buf, 4, byte_order));
regcache_raw_write (regcache, rawnum, buf64);
}
anyway. */
static CORE_ADDR
-mep_get_insn (CORE_ADDR pc, long *insn)
+mep_get_insn (struct gdbarch *gdbarch, CORE_ADDR pc, long *insn)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int pc_in_vliw_section;
int vliw_mode;
int insn_len;
vliw_mode = 0;
read_memory (pc, buf, sizeof (buf));
- *insn = extract_unsigned_integer (buf, 2) << 16;
+ *insn = extract_unsigned_integer (buf, 2, byte_order) << 16;
/* The major opcode --- the top four bits of the first 16-bit
part --- indicates whether this instruction is 16 or 32 bits
{
/* Fetch the second 16-bit part of the instruction. */
read_memory (pc + 2, buf, sizeof (buf));
- *insn = *insn | extract_unsigned_integer (buf, 2);
+ *insn = *insn | extract_unsigned_integer (buf, 2, byte_order);
}
/* If we're in VLIW code, then the VLIW width determines the address
CORE_ADDR next_pc;
pv_t pre_insn_fp, pre_insn_sp;
- next_pc = mep_get_insn (pc, &insn);
+ next_pc = mep_get_insn (gdbarch, pc, &insn);
/* A zero return from mep_get_insn means that either we weren't
able to read the instruction from memory, or that we don't
int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR *copy = (CORE_ADDR *) alloca (argc * sizeof (copy[0]));
CORE_ADDR func_addr = find_function_addr (function, NULL);
int i;
/* Arguments that fit in a GPR get expanded to fill the GPR. */
if (arg_size <= MEP_GPR_SIZE)
value = extract_unsigned_integer (value_contents (argv[i]),
- TYPE_LENGTH (value_type (argv[i])));
+ TYPE_LENGTH (value_type (argv[i])),
+ byte_order);
/* Arguments too large to fit in a GPR get copied to the stack,
and we pass a pointer to the copy. */
else
{
char buf[MEP_GPR_SIZE];
- store_unsigned_integer (buf, MEP_GPR_SIZE, value);
+ store_unsigned_integer (buf, MEP_GPR_SIZE, byte_order, value);
write_memory (arg_stack, buf, MEP_GPR_SIZE);
arg_stack += MEP_GPR_SIZE;
}
void
mi_cmd_data_write_memory (char *command, char **argv, int argc)
{
+ struct gdbarch *gdbarch = get_current_arch ();
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR addr;
char word_format;
long word_size;
/* Get the value into an array. */
buffer = xmalloc (word_size);
old_chain = make_cleanup (xfree, buffer);
- store_signed_integer (buffer, word_size, value);
+ store_signed_integer (buffer, word_size, byte_order, value);
/* Write it down to memory. */
write_memory (addr, buffer, word_size);
/* Free the buffer. */
{
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT];
jb_addr = get_frame_register_unsigned (frame, MIPS_A0_REGNUM);
return 0;
*pc = extract_unsigned_integer (buf,
- gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+ gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
+ byte_order);
return 1;
}
static void
supply_32bit_reg (struct regcache *regcache, int regnum, const void *addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[MAX_REGISTER_SIZE];
- store_signed_integer (buf,
- register_size (get_regcache_arch (regcache), regnum),
- extract_signed_integer (addr, 4));
+ store_signed_integer (buf, register_size (gdbarch, regnum), byte_order,
+ extract_signed_integer (addr, 4, byte_order));
regcache_raw_supply (regcache, regnum, buf);
}
{
CORE_ADDR jb_addr;
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
void *buf = alloca (gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
int element_size = gdbarch_ptr_bit (gdbarch) == 32 ? 4 : 8;
return 0;
*pc = extract_unsigned_integer (buf,
- gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT);
+ gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT,
+ byte_order);
return 1;
}
mips64_elf_gregset_t *gregsetp, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int regaddr, regi;
mips64_elf_greg_t *regp = *gregsetp;
void *dst;
LONGEST val;
regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno));
+ val = extract_signed_integer (buf, register_size (gdbarch, regno),
+ byte_order);
dst = regp + regaddr;
- store_signed_integer (dst, 8, val);
+ store_signed_integer (dst, 8, byte_order, val);
}
}
mips64_elf_fpregset_t *fpregsetp, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte *to;
if ((regno >= gdbarch_fp0_regnum (gdbarch))
LONGEST val;
regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno));
+ val = extract_signed_integer (buf, register_size (gdbarch, regno),
+ byte_order);
to = (gdb_byte *) (*fpregsetp + 32);
- store_signed_integer (to, 4, val);
+ store_signed_integer (to, 4, byte_order, val);
}
else if (regno == mips_regnum (gdbarch)->fp_implementation_revision)
{
LONGEST val;
regcache_raw_collect (regcache, regno, buf);
- val = extract_signed_integer (buf, register_size (gdbarch, regno));
+ val = extract_signed_integer (buf, register_size (gdbarch, regno),
+ byte_order);
to = (gdb_byte *) (*fpregsetp + 32) + 4;
- store_signed_integer (to, 4, val);
+ store_signed_integer (to, 4, byte_order, val);
}
else if (regno == -1)
{
unsigned char buf[28], *p;
ULONGEST insn, insn1;
int n64 = (mips_abi (target_gdbarch) == MIPS_ABI_N64);
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
read_memory (pc - 12, buf, 28);
p = buf + 12;
while (p >= buf)
{
- insn = extract_unsigned_integer (p, 4);
+ insn = extract_unsigned_integer (p, 4, byte_order);
if (insn == insn1)
break;
p -= 4;
if (p < buf)
return 0;
- insn = extract_unsigned_integer (p + 4, 4);
+ insn = extract_unsigned_integer (p + 4, 4, byte_order);
if (n64)
{
/* daddu t7,ra */
return 0;
}
- insn = extract_unsigned_integer (p + 8, 4);
+ insn = extract_unsigned_integer (p + 8, 4, byte_order);
/* jalr t9,ra */
if (insn != 0x0320f809)
return 0;
- insn = extract_unsigned_integer (p + 12, 4);
+ insn = extract_unsigned_integer (p + 12, 4, byte_order);
if (n64)
{
/* daddiu t8,zero,0 */
is odd, assume it's a MIPS16 instruction; otherwise MIPS32. */
static ULONGEST
-mips_fetch_instruction (CORE_ADDR addr)
+mips_fetch_instruction (struct gdbarch *gdbarch, CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[MIPS_INSN32_SIZE];
int instlen;
int status;
status = target_read_memory (addr, buf, instlen);
if (status)
memory_error (status, addr);
- return extract_unsigned_integer (buf, instlen);
+ return extract_unsigned_integer (buf, instlen, byte_order);
}
/* These the fields of 32 bit mips instructions */
static CORE_ADDR
mips32_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
unsigned long inst;
int op;
- inst = mips_fetch_instruction (pc);
+ inst = mips_fetch_instruction (gdbarch, pc);
if ((inst & 0xe0000000) != 0) /* Not a special, jump or branch instruction */
{
if (itype_op (inst) >> 2 == 5)
when the offset is to be used in relative addressing. */
static unsigned int
-fetch_mips_16 (CORE_ADDR pc)
+fetch_mips_16 (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[8];
pc &= 0xfffffffe; /* clear the low order bit */
target_read_memory (pc, buf, 2);
- return extract_unsigned_integer (buf, 2);
+ return extract_unsigned_integer (buf, 2, byte_order);
}
static void
-unpack_mips16 (CORE_ADDR pc,
+unpack_mips16 (struct gdbarch *gdbarch, CORE_ADDR pc,
unsigned int extension,
unsigned int inst,
enum mips16_inst_fmts insn_format, struct upk_mips16 *upk)
unsigned int nexthalf;
value = ((inst & 0x1f) << 5) | ((inst >> 5) & 0x1f);
value = value << 16;
- nexthalf = mips_fetch_instruction (pc + 2); /* low bit still set */
+ nexthalf = mips_fetch_instruction (gdbarch, pc + 2); /* low bit still set */
value |= nexthalf;
offset = value;
regx = -1;
extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
unsigned int extension, unsigned int insn)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
int op = (insn >> 11);
switch (op)
{
{
CORE_ADDR offset;
struct upk_mips16 upk;
- unpack_mips16 (pc, extension, insn, itype, &upk);
+ unpack_mips16 (gdbarch, pc, extension, insn, itype, &upk);
offset = upk.offset;
if (offset & 0x800)
{
case 3: /* JAL , JALX - Watch out, these are 32 bit instruction */
{
struct upk_mips16 upk;
- unpack_mips16 (pc, extension, insn, jalxtype, &upk);
+ unpack_mips16 (gdbarch, pc, extension, insn, jalxtype, &upk);
pc = add_offset_16 (pc, upk.offset);
if ((insn >> 10) & 0x01) /* Exchange mode */
pc = pc & ~0x01; /* Clear low bit, indicate 32 bit mode */
{
struct upk_mips16 upk;
int reg;
- unpack_mips16 (pc, extension, insn, ritype, &upk);
+ unpack_mips16 (gdbarch, pc, extension, insn, ritype, &upk);
reg = get_frame_register_signed (frame, upk.regx);
if (reg == 0)
pc += (upk.offset << 1) + 2;
{
struct upk_mips16 upk;
int reg;
- unpack_mips16 (pc, extension, insn, ritype, &upk);
+ unpack_mips16 (gdbarch, pc, extension, insn, ritype, &upk);
reg = get_frame_register_signed (frame, upk.regx);
if (reg != 0)
pc += (upk.offset << 1) + 2;
{
struct upk_mips16 upk;
int reg;
- unpack_mips16 (pc, extension, insn, i8type, &upk);
+ unpack_mips16 (gdbarch, pc, extension, insn, i8type, &upk);
/* upk.regx contains the opcode */
reg = get_frame_register_signed (frame, 24); /* Test register is 24 */
if (((upk.regx == 0) && (reg == 0)) /* BTEZ */
that. */
{
pc += 2;
- pc = extended_mips16_next_pc (frame, pc, insn, fetch_mips_16 (pc));
+ pc = extended_mips16_next_pc (frame, pc, insn,
+ fetch_mips_16 (gdbarch, pc));
break;
}
default:
static CORE_ADDR
mips16_next_pc (struct frame_info *frame, CORE_ADDR pc)
{
- unsigned int insn = fetch_mips_16 (pc);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ unsigned int insn = fetch_mips_16 (gdbarch, pc);
return extended_mips16_next_pc (frame, pc, 0, insn);
}
Return the address of the first instruction past the prologue. */
static CORE_ADDR
-mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
+mips16_scan_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start_pc, CORE_ADDR limit_pc,
struct frame_info *this_frame,
struct mips_frame_cache *this_cache)
{
int extend_bytes = 0;
int prev_extend_bytes;
CORE_ADDR end_prologue_addr = 0;
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
/* Can be called when there's no process, and hence when there's no
THIS_FRAME. */
prev_inst = inst;
/* Fetch and decode the instruction. */
- inst = (unsigned short) mips_fetch_instruction (cur_pc);
+ inst = (unsigned short) mips_fetch_instruction (gdbarch, cur_pc);
/* Normally we ignore extend instructions. However, if it is
not followed by a valid prologue instruction, then this
static struct mips_frame_cache *
mips_insn16_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct mips_frame_cache *cache;
if ((*this_cache) != NULL)
find_pc_partial_function (pc, NULL, &start_addr, NULL);
if (start_addr == 0)
- start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
+ start_addr = heuristic_proc_start (gdbarch, pc);
/* We can't analyze the prologue if we couldn't find the begining
of the function. */
if (start_addr == 0)
return cache;
- mips16_scan_prologue (start_addr, pc, this_frame, *this_cache);
+ mips16_scan_prologue (gdbarch, start_addr, pc, this_frame, *this_cache);
}
/* gdbarch_sp_regnum contains the value and not the address. */
trad_frame_set_value (cache->saved_regs,
- gdbarch_num_regs (get_frame_arch (this_frame))
- + MIPS_SP_REGNUM,
+ gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
cache->base);
return (*this_cache);
Return the address of the first instruction past the prologue. */
static CORE_ADDR
-mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
+mips32_scan_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start_pc, CORE_ADDR limit_pc,
struct frame_info *this_frame,
struct mips_frame_cache *this_cache)
{
int seen_sp_adjust = 0;
int load_immediate_bytes = 0;
int in_delay_slot = 0;
- struct gdbarch *gdbarch = get_frame_arch (this_frame);
int regsize_is_64_bits = (mips_abi_regsize (gdbarch) == 8);
/* Can be called when there's no process, and hence when there's no
int reg;
/* Fetch the instruction. */
- inst = (unsigned long) mips_fetch_instruction (cur_pc);
+ inst = (unsigned long) mips_fetch_instruction (gdbarch, cur_pc);
/* Save some code by pre-extracting some useful fields. */
high_word = (inst >> 16) & 0xffff;
static struct mips_frame_cache *
mips_insn32_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct mips_frame_cache *cache;
if ((*this_cache) != NULL)
find_pc_partial_function (pc, NULL, &start_addr, NULL);
if (start_addr == 0)
- start_addr = heuristic_proc_start (get_frame_arch (this_frame), pc);
+ start_addr = heuristic_proc_start (gdbarch, pc);
/* We can't analyze the prologue if we couldn't find the begining
of the function. */
if (start_addr == 0)
return cache;
- mips32_scan_prologue (start_addr, pc, this_frame, *this_cache);
+ mips32_scan_prologue (gdbarch, start_addr, pc, this_frame, *this_cache);
}
/* gdbarch_sp_regnum contains the value and not the address. */
trad_frame_set_value (cache->saved_regs,
- gdbarch_num_regs (get_frame_arch (this_frame))
- + MIPS_SP_REGNUM,
+ gdbarch_num_regs (gdbarch) + MIPS_SP_REGNUM,
cache->base);
return (*this_cache);
if (pc & 0x01)
return 0;
- insn = mips_fetch_instruction (loc);
+ insn = mips_fetch_instruction (gdbarch, loc);
/* Assume all atomic sequences start with a ll/lld instruction. */
if (itype_op (insn) != LL_OPCODE && itype_op (insn) != LLD_OPCODE)
return 0;
{
int is_branch = 0;
loc += MIPS_INSN32_SIZE;
- insn = mips_fetch_instruction (loc);
+ insn = mips_fetch_instruction (gdbarch, loc);
/* Assume that there is at most one branch in the atomic
sequence. If a branch is found, put a breakpoint in its
end of a function. */
static int
-mips_about_to_return (CORE_ADDR pc)
+mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)
{
if (mips_pc_is_mips16 (pc))
/* This mips16 case isn't necessarily reliable. Sometimes the compiler
as $a3), then a "jr" using that register. This second case
is almost impossible to distinguish from an indirect jump
used for switch statements, so we don't even try. */
- return mips_fetch_instruction (pc) == 0xe820; /* jr $ra */
+ return mips_fetch_instruction (gdbarch, pc) == 0xe820; /* jr $ra */
else
- return mips_fetch_instruction (pc) == 0x3e00008; /* jr $ra */
+ return mips_fetch_instruction (gdbarch, pc) == 0x3e00008; /* jr $ra */
}
addiu sp,-n
daddiu sp,-n
extend -n followed by 'addiu sp,+n' or 'daddiu sp,+n' */
- inst = mips_fetch_instruction (start_pc);
+ inst = mips_fetch_instruction (gdbarch, start_pc);
if ((inst & 0xff80) == 0x6480) /* save */
{
if (start_pc - instlen >= fence)
{
- inst = mips_fetch_instruction (start_pc - instlen);
+ inst = mips_fetch_instruction (gdbarch, start_pc - instlen);
if ((inst & 0xf800) == 0xf000) /* extend */
start_pc -= instlen;
}
else
seen_adjsp = 0;
}
- else if (mips_about_to_return (start_pc))
+ else if (mips_about_to_return (gdbarch, start_pc))
{
/* Skip return and its delay slot. */
start_pc += 2 * MIPS_INSN32_SIZE;
int len = 0;
int stack_offset = 0;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
int regsize = mips_abi_regsize (gdbarch);
if (len > regsize
&& (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION))
{
- store_unsigned_integer (valbuf, regsize, value_address (arg));
+ store_unsigned_integer (valbuf, regsize, byte_order,
+ value_address (arg));
typecode = TYPE_CODE_PTR;
len = regsize;
val = valbuf;
unsigned long regval;
/* Write the low word of the double to the even register(s). */
- regval = extract_unsigned_integer (val + low_offset, 4);
+ regval = extract_unsigned_integer (val + low_offset,
+ 4, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, 4));
regcache_cooked_write_unsigned (regcache, float_argreg++, regval);
/* Write the high word of the double to the odd register(s). */
- regval = extract_unsigned_integer (val + 4 - low_offset, 4);
+ regval = extract_unsigned_integer (val + 4 - low_offset,
+ 4, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, 4));
in a single register. */
/* On 32 bit ABI's the float_argreg is further adjusted
above to ensure that it is even register aligned. */
- LONGEST regval = extract_unsigned_integer (val, len);
+ LONGEST regval = extract_unsigned_integer (val, len, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, len));
&& !fp_register_arg_p (gdbarch, typecode, arg_type))
{
LONGEST regval =
- extract_unsigned_integer (val, partial_len);
+ extract_unsigned_integer (val, partial_len, byte_order);
if (mips_debug)
fprintf_filtered (gdb_stdlog, " - reg=%d val=%s",
int len = 0;
int stack_offset = 0;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
/* For shared libraries, "t9" needs to point at the function
/* This is a floating point value that fits entirely
in a single register or a pair of registers. */
int reglen = (len <= MIPS64_REGSIZE ? len : MIPS64_REGSIZE);
- LONGEST regval = extract_unsigned_integer (val, reglen);
+ LONGEST regval = extract_unsigned_integer (val, reglen, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, reglen));
argreg++;
if (len == 16)
{
- regval = extract_unsigned_integer (val + reglen, reglen);
+ regval = extract_unsigned_integer (val + reglen,
+ reglen, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, reglen));
|| (partial_len < 4
&& typecode == TYPE_CODE_INT
&& !TYPE_UNSIGNED (arg_type)))
- regval = extract_signed_integer (val, partial_len);
+ regval = extract_signed_integer (val, partial_len,
+ byte_order);
else
- regval = extract_unsigned_integer (val, partial_len);
+ regval = extract_unsigned_integer (val, partial_len,
+ byte_order);
/* A non-floating-point argument being passed in a
general register. If a struct or union, and if
int len = 0;
int stack_offset = 0;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
/* For shared libraries, "t9" needs to point at the function
unsigned long regval;
/* Write the low word of the double to the even register(s). */
- regval = extract_unsigned_integer (val + low_offset, 4);
+ regval = extract_unsigned_integer (val + low_offset,
+ 4, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, 4));
regcache_cooked_write_unsigned (regcache, argreg++, regval);
/* Write the high word of the double to the odd register(s). */
- regval = extract_unsigned_integer (val + 4 - low_offset, 4);
+ regval = extract_unsigned_integer (val + 4 - low_offset,
+ 4, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, 4));
in a single register. */
/* On 32 bit ABI's the float_argreg is further adjusted
above to ensure that it is even register aligned. */
- LONGEST regval = extract_unsigned_integer (val, len);
+ LONGEST regval = extract_unsigned_integer (val, len, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, len));
purpose register. */
if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
{
- LONGEST regval = extract_signed_integer (val, partial_len);
+ LONGEST regval = extract_signed_integer (val, partial_len,
+ byte_order);
/* Value may need to be sign extended, because
mips_isa_regsize() != mips_abi_regsize(). */
int len = 0;
int stack_offset = 0;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = find_function_addr (function, NULL);
/* For shared libraries, "t9" needs to point at the function
if (fp_register_arg_p (gdbarch, typecode, arg_type)
&& float_argreg <= MIPS_LAST_FP_ARG_REGNUM (gdbarch))
{
- LONGEST regval = extract_unsigned_integer (val, len);
+ LONGEST regval = extract_unsigned_integer (val, len, byte_order);
if (mips_debug)
fprintf_unfiltered (gdb_stdlog, " - fpreg=%d val=%s",
float_argreg, phex (regval, len));
purpose register. */
if (argreg <= MIPS_LAST_ARG_REGNUM (gdbarch))
{
- LONGEST regval = extract_signed_integer (val, partial_len);
+ LONGEST regval = extract_signed_integer (val, partial_len,
+ byte_order);
/* Value may need to be sign extended, because
mips_isa_regsize() != mips_abi_regsize(). */
mips_single_step_through_delay (struct gdbarch *gdbarch,
struct frame_info *frame)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc = get_frame_pc (frame);
gdb_byte buf[MIPS_INSN32_SIZE];
/* If error reading memory, guess that it is not a delayed
branch. */
return 0;
- return is_delayed (extract_unsigned_integer (buf, sizeof buf));
+ return is_delayed (extract_unsigned_integer (buf, sizeof buf, byte_order));
}
/* To skip prologues, I use this predicate. Returns either PC itself
limit_pc = pc + 100; /* Magic. */
if (mips_pc_is_mips16 (pc))
- return mips16_scan_prologue (pc, limit_pc, NULL, NULL);
+ return mips16_scan_prologue (gdbarch, pc, limit_pc, NULL, NULL);
else
- return mips32_scan_prologue (pc, limit_pc, NULL, NULL);
+ return mips32_scan_prologue (gdbarch, pc, limit_pc, NULL, NULL);
}
/* Check whether the PC is in a function epilogue (32-bit version).
This is a helper function for mips_in_function_epilogue_p. */
static int
-mips32_in_function_epilogue_p (CORE_ADDR pc)
+mips32_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0, func_end = 0;
unsigned long high_word;
unsigned long inst;
- inst = mips_fetch_instruction (pc);
+ inst = mips_fetch_instruction (gdbarch, pc);
high_word = (inst >> 16) & 0xffff;
if (high_word != 0x27bd /* addiu $sp,$sp,offset */
/* Check whether the PC is in a function epilogue (16-bit version).
This is a helper function for mips_in_function_epilogue_p. */
static int
-mips16_in_function_epilogue_p (CORE_ADDR pc)
+mips16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
CORE_ADDR func_addr = 0, func_end = 0;
{
unsigned short inst;
- inst = mips_fetch_instruction (pc);
+ inst = mips_fetch_instruction (gdbarch, pc);
if ((inst & 0xf800) == 0xf000) /* extend */
continue;
mips_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
if (mips_pc_is_mips16 (pc))
- return mips16_in_function_epilogue_p (pc);
+ return mips16_in_function_epilogue_p (gdbarch, pc);
else
- return mips32_in_function_epilogue_p (pc);
+ return mips32_in_function_epilogue_p (gdbarch, pc);
}
/* Root of all "set mips "/"show mips " commands. This will eventually be
static CORE_ADDR
mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
char *name;
CORE_ADDR start_addr;
instructions. FIXME. */
for (i = 0, pc = 0; i < 20; i++, target_pc += MIPS_INSN32_SIZE)
{
- inst = mips_fetch_instruction (target_pc);
+ inst = mips_fetch_instruction (gdbarch, target_pc);
if ((inst & 0xffff0000) == 0x3c010000) /* lui $at */
pc = (inst << 16) & 0xffff0000; /* high word */
else if ((inst & 0xffff0000) == 0x24210000) /* addiu $at */
static CORE_ADDR
mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct minimal_symbol *msym;
int i;
gdb_byte stub_code[16];
if (target_read_memory (pc, stub_code, 16) != 0)
return 0;
for (i = 0; i < 4; i++)
- stub_words[i] = extract_unsigned_integer (stub_code + i * 4, 4);
+ stub_words[i] = extract_unsigned_integer (stub_code + i * 4,
+ 4, byte_order);
/* A stub contains these instructions:
lui t9, %hi(target)
mips_integer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
- return (CORE_ADDR) extract_signed_integer (buf, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return extract_signed_integer (buf, TYPE_LENGTH (type), byte_order);
}
/* Dummy virtual frame pointer method. This is no more or less accurate
mipsnbsd_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR jb_addr;
char *buf;
NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch)))
return 0;
- *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch));
-
+ *pc = extract_unsigned_integer (buf, NBSD_MIPS_JB_ELEMENT_SIZE (gdbarch),
+ byte_order);
return 1;
}
CORE_ADDR start_pc, CORE_ADDR limit_pc,
struct mn10300_prologue *result)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc, next_pc;
int rn;
pv_t regs[MN10300_MAX_NUM_REGS];
if (status != 0)
break;
- imm8 = extract_signed_integer (buf, 1);
+ imm8 = extract_signed_integer (buf, 1, byte_order);
regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm8);
pc += 3;
if (status != 0)
break;
- imm16 = extract_signed_integer (buf, 2);
+ imm16 = extract_signed_integer (buf, 2, byte_order);
regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm16);
pc += 4;
break;
- imm32 = extract_signed_integer (buf, 4);
+ imm32 = extract_signed_integer (buf, 4, byte_order);
regs[E_SP_REGNUM] = pv_add_constant (regs[E_SP_REGNUM], imm32);
pc += 6;
LONGEST imm8;
aN = instr[0] & 0x03;
- imm8 = extract_signed_integer (&instr[1], 1);
+ imm8 = extract_signed_integer (&instr[1], 1, byte_order);
regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
imm8);
break;
- imm16 = extract_signed_integer (buf, 2);
+ imm16 = extract_signed_integer (buf, 2, byte_order);
regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
imm16);
if (status != 0)
break;
- imm32 = extract_signed_integer (buf, 2);
+ imm32 = extract_signed_integer (buf, 2, byte_order);
regs[E_A0_REGNUM + aN] = pv_add_constant (regs[E_A0_REGNUM + aN],
imm32);
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- d8 = extract_signed_integer (&buf[1], 1);
+ d8 = extract_signed_integer (&buf[1], 1, byte_order);
pv_area_store (stack,
pv_add_constant (regs[translate_rreg (rN)], d8),
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- d24 = extract_signed_integer (&buf[1], 3);
+ d24 = extract_signed_integer (&buf[1], 3, byte_order);
pv_area_store (stack,
pv_add_constant (regs[translate_rreg (rN)], d24),
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- d32 = extract_signed_integer (&buf[1], 4);
+ d32 = extract_signed_integer (&buf[1], 4, byte_order);
pv_area_store (stack,
pv_add_constant (regs[translate_rreg (rN)], d32),
sM = (buf[0] & 0xf0) >> 4;
fsM = (Y << 4) | sM;
- d8 = extract_signed_integer (&buf[1], 1);
+ d8 = extract_signed_integer (&buf[1], 1, byte_order);
pv_area_store (stack,
pv_add_constant (regs[E_SP_REGNUM], d8),
sM = (buf[0] & 0xf0) >> 4;
fsM = (Y << 4) | sM;
- d24 = extract_signed_integer (&buf[1], 3);
+ d24 = extract_signed_integer (&buf[1], 3, byte_order);
pv_area_store (stack,
pv_add_constant (regs[E_SP_REGNUM], d24),
sM = (buf[0] & 0xf0) >> 4;
fsM = (Y << 4) | sM;
- d32 = extract_signed_integer (&buf[1], 4);
+ d32 = extract_signed_integer (&buf[1], 4, byte_order);
pv_area_store (stack,
pv_add_constant (regs[E_SP_REGNUM], d32),
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- imm8 = extract_signed_integer (&buf[1], 1);
+ imm8 = extract_signed_integer (&buf[1], 1, byte_order);
rN_regnum = translate_rreg (rN);
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- imm24 = extract_signed_integer (&buf[1], 3);
+ imm24 = extract_signed_integer (&buf[1], 3, byte_order);
rN_regnum = translate_rreg (rN);
sM = (buf[0] & 0xf0) >> 4;
rN = buf[0] & 0x0f;
fsM = (Y << 4) | sM;
- imm32 = extract_signed_integer (&buf[1], 4);
+ imm32 = extract_signed_integer (&buf[1], 4, byte_order);
rN_regnum = translate_rreg (rN);
int aN = instr[0] & 0x03;
LONGEST imm8;
- imm8 = extract_signed_integer (&instr[1], 1);
+ imm8 = extract_signed_integer (&instr[1], 1, byte_order);
regs[E_A0_REGNUM + aN] = pv_constant (imm8);
pc += 2;
if (status != 0)
break;
- imm16 = extract_signed_integer (buf, 2);
+ imm16 = extract_signed_integer (buf, 2, byte_order);
regs[E_A0_REGNUM + aN] = pv_constant (imm16);
pc += 3;
}
if (status != 0)
break;
- imm32 = extract_signed_integer (buf, 4);
+ imm32 = extract_signed_integer (buf, 4, byte_order);
regs[E_A0_REGNUM + aN] = pv_constant (imm32);
pc += 6;
}
int dN = instr[0] & 0x03;
LONGEST imm8;
- imm8 = extract_signed_integer (&instr[1], 1);
+ imm8 = extract_signed_integer (&instr[1], 1, byte_order);
regs[E_D0_REGNUM + dN] = pv_constant (imm8);
pc += 2;
if (status != 0)
break;
- imm16 = extract_signed_integer (buf, 2);
+ imm16 = extract_signed_integer (buf, 2, byte_order);
regs[E_D0_REGNUM + dN] = pv_constant (imm16);
pc += 3;
}
if (status != 0)
break;
- imm32 = extract_signed_integer (buf, 4);
+ imm32 = extract_signed_integer (buf, 4, byte_order);
regs[E_D0_REGNUM + dN] = pv_constant (imm32);
pc += 6;
}
int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
const int push_size = register_size (gdbarch, E_PC_REGNUM);
int regs_used;
int len, arg_len;
{
/* Change to pointer-to-type. */
arg_len = push_size;
- store_unsigned_integer (valbuf, push_size,
+ store_unsigned_integer (valbuf, push_size, byte_order,
value_address (*args));
val = &valbuf[0];
}
while (regs_used < 2 && arg_len > 0)
{
regcache_cooked_write_unsigned (regcache, regs_used,
- extract_unsigned_integer (val, push_size));
+ extract_unsigned_integer (val, push_size, byte_order));
val += push_size;
arg_len -= push_size;
regs_used++;
/* Push the return address that contains the magic breakpoint. */
sp -= 4;
- write_memory_unsigned_integer (sp, push_size, bp_addr);
+ write_memory_unsigned_integer (sp, push_size, byte_order, bp_addr);
/* The CPU also writes the return address always into the
MDR register on "call". */
char *
monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
unsigned char regbuf[MAX_REGISTER_SIZE];
char *p;
/* supply register stores in target byte order, so swap here */
- store_unsigned_integer (regbuf,
- register_size (get_regcache_arch (regcache), regno),
+ store_unsigned_integer (regbuf, register_size (gdbarch, regno), byte_order,
val);
regcache_raw_supply (regcache, regno, regbuf);
static int
monitor_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
unsigned int val, hostval;
char *cmd;
int i;
cmd = current_monitor->setmem.cmdb;
}
- val = extract_unsigned_integer (myaddr, len);
+ val = extract_unsigned_integer (myaddr, len, byte_order);
if (len == 4)
{
static int
monitor_read_memory_single (CORE_ADDR memaddr, char *myaddr, int len)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
unsigned int val;
char membuf[sizeof (int) * 2 + 1];
char *p;
/* supply register stores in target byte order, so swap here */
- store_unsigned_integer (myaddr, len, val);
+ store_unsigned_integer (myaddr, len, byte_order, val);
return len;
}
moxie_store_return_value (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR regval;
int len = TYPE_LENGTH (type);
/* Things always get returned in RET1_REGNUM, RET2_REGNUM. */
- regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len);
+ regval = extract_unsigned_integer (valbuf, len > 4 ? 4 : len, byte_order);
regcache_cooked_write_unsigned (regcache, RET1_REGNUM, regval);
if (len > 4)
{
- regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4, len - 4);
+ regval = extract_unsigned_integer ((gdb_byte *) valbuf + 4,
+ len - 4, byte_order);
regcache_cooked_write_unsigned (regcache, RET1_REGNUM + 1, regval);
}
}
struct moxie_frame_cache *cache,
struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR next_addr;
ULONGEST inst, inst2;
LONGEST offset;
for (next_addr = start_addr; next_addr < end_addr; )
{
- inst = read_memory_unsigned_integer (next_addr, 2);
+ inst = read_memory_unsigned_integer (next_addr, 2, byte_order);
/* Match "push $rN" where N is between 2 and 13 inclusive. */
if (inst >= 0x0614 && inst <= 0x061f)
byte. */
else if (inst == 0x01f0) /* ldi.l $r12, X */
{
- offset = read_memory_integer (next_addr + 2, 4);
- inst2 = read_memory_unsigned_integer (next_addr + 6, 2);
+ offset = read_memory_integer (next_addr + 2, 4, byte_order);
+ inst2 = read_memory_unsigned_integer (next_addr + 6, 2, byte_order);
if (inst2 == 0x051f) /* add.l $sp, $r12 */
{
moxie_extract_return_value (struct type *type, struct regcache *regcache,
void *dst)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
bfd_byte *valbuf = dst;
int len = TYPE_LENGTH (type);
ULONGEST tmp;
/* By using store_unsigned_integer we avoid having to do
anything special for small big-endian values. */
regcache_cooked_read_unsigned (regcache, RET1_REGNUM, &tmp);
- store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), tmp);
+ store_unsigned_integer (valbuf, (len > 4 ? len - 4 : len), byte_order, tmp);
/* Ignore return values more than 8 bytes in size because the moxie
returns anything more than 8 bytes in the stack. */
if (len > 4)
{
regcache_cooked_read_unsigned (regcache, RET1_REGNUM + 1, &tmp);
- store_unsigned_integer (valbuf + len - 4, 4, tmp);
+ store_unsigned_integer (valbuf + len - 4, 4, byte_order, tmp);
}
}
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
if (TYPE_LENGTH (type) > 4)
{
/* Return values > 4 bytes are returned in memory,
/* Return values of <= 4 bytes are returned in R11. */
regcache_cooked_read_unsigned (regcache, MT_R11_REGNUM, &temp);
- store_unsigned_integer (readbuf, TYPE_LENGTH (type), temp);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (type),
+ byte_order, temp);
}
if (writebuf)
static CORE_ADDR
mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = 0, func_end = 0;
char *func_name;
unsigned long instr;
/* No function symbol, or no line symbol. Use prologue scanning method. */
for (;; pc += 4)
{
- instr = read_memory_unsigned_integer (pc, 4);
+ instr = read_memory_unsigned_integer (pc, 4, byte_order);
if (instr == 0x12000000) /* nop */
continue;
if (instr == 0x12ddc000) /* copy sp into fp */
mt_select_coprocessor (struct gdbarch *gdbarch,
struct regcache *regcache, int regno)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned index, base;
gdb_byte copro[4];
/* Get the copro pseudo regnum. */
regcache_raw_read (regcache, MT_COPRO_REGNUM, copro);
- base = (extract_signed_integer (&copro[0], 2) * MT_COPRO_PSEUDOREG_DIM_2
- + extract_signed_integer (&copro[2], 2));
+ base = ((extract_signed_integer (&copro[0], 2, byte_order)
+ * MT_COPRO_PSEUDOREG_DIM_2)
+ + extract_signed_integer (&copro[2], 2, byte_order));
regno -= MT_COPRO_PSEUDOREG_ARRAY;
index = regno % MT_COPRO_PSEUDOREG_REGS;
coprocessor register cache. */
unsigned ix;
- store_signed_integer (&copro[0], 2, regno / MT_COPRO_PSEUDOREG_DIM_2);
- store_signed_integer (&copro[2], 2, regno % MT_COPRO_PSEUDOREG_DIM_2);
+ store_signed_integer (&copro[0], 2, byte_order,
+ regno / MT_COPRO_PSEUDOREG_DIM_2);
+ store_signed_integer (&copro[2], 2, byte_order,
+ regno % MT_COPRO_PSEUDOREG_DIM_2);
regcache_raw_write (regcache, MT_COPRO_REGNUM, copro);
/* We must flush the cache, as it is now invalid. */
mt_pseudo_register_read (struct gdbarch *gdbarch,
struct regcache *regcache, int regno, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
switch (regno)
{
case MT_COPRO_REGNUM:
regcache_cooked_read_unsigned (regcache, MT_EXMAC_REGNUM, &ext_mac);
newmac =
(oldmac & 0xffffffff) | ((long long) (ext_mac & 0xff) << 32);
- store_signed_integer (buf, 8, newmac);
+ store_signed_integer (buf, 8, byte_order, newmac);
}
else
regcache_raw_read (regcache, MT_MAC_REGNUM, buf);
struct regcache *regcache,
int regno, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
switch (regno)
unsigned int oldmac, ext_mac;
ULONGEST newmac;
- newmac = extract_unsigned_integer (buf, 8);
+ newmac = extract_unsigned_integer (buf, 8, byte_order);
oldmac = newmac & 0xffffffff;
ext_mac = (newmac >> 32) & 0xff;
regcache_cooked_write_unsigned (regcache, MT_MAC_REGNUM, oldmac);
struct ui_file *file,
struct frame_info *frame, int regnum, int all)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
if (regnum == -1)
{
int lim;
for (i = 0; i < regsize; i++)
fprintf_filtered (file, "%02x", (unsigned int)
- extract_unsigned_integer (buff + i, 1));
+ extract_unsigned_integer (buff + i, 1, byte_order));
fputs_filtered ("\t", file);
print_longest (file, 'd', 0,
- extract_unsigned_integer (buff, regsize));
+ extract_unsigned_integer (buff, regsize, byte_order));
fputs_filtered ("\n", file);
}
else if (regnum == MT_COPRO_REGNUM
/* Get the two "real" mac registers. */
frame_register_read (frame, MT_MAC_REGNUM, buf);
oldmac = extract_unsigned_integer
- (buf, register_size (gdbarch, MT_MAC_REGNUM));
+ (buf, register_size (gdbarch, MT_MAC_REGNUM), byte_order);
if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_mrisc2
|| gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_ms2)
{
frame_register_read (frame, MT_EXMAC_REGNUM, buf);
ext_mac = extract_unsigned_integer
- (buf, register_size (gdbarch, MT_EXMAC_REGNUM));
+ (buf, register_size (gdbarch, MT_EXMAC_REGNUM), byte_order);
}
else
ext_mac = 0;
int struct_return, CORE_ADDR struct_addr)
{
#define wordsize 4
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[MT_MAX_STRUCT_SIZE];
int argreg = MT_1ST_ARGREG;
int split_param_len = 0;
regcache_cooked_write_unsigned (regcache, argreg++,
extract_unsigned_integer
(value_contents (args[i]),
- wordsize));
+ wordsize, byte_order));
break;
case 8:
case 12:
/* This word of the argument is passed in a register. */
regcache_cooked_write_unsigned (regcache, argreg++,
extract_unsigned_integer
- (val, wordsize));
+ (val, wordsize, byte_order));
typelen -= wordsize;
val += wordsize;
}
}
static void
-read_objc_method (CORE_ADDR addr, struct objc_method *method)
+read_objc_method (struct gdbarch *gdbarch, CORE_ADDR addr,
+ struct objc_method *method)
{
- method->name = read_memory_unsigned_integer (addr + 0, 4);
- method->types = read_memory_unsigned_integer (addr + 4, 4);
- method->imp = read_memory_unsigned_integer (addr + 8, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ method->name = read_memory_unsigned_integer (addr + 0, 4, byte_order);
+ method->types = read_memory_unsigned_integer (addr + 4, 4, byte_order);
+ method->imp = read_memory_unsigned_integer (addr + 8, 4, byte_order);
}
-static
-unsigned long read_objc_methlist_nmethods (CORE_ADDR addr)
+static unsigned long
+read_objc_methlist_nmethods (struct gdbarch *gdbarch, CORE_ADDR addr)
{
- return read_memory_unsigned_integer (addr + 4, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ return read_memory_unsigned_integer (addr + 4, 4, byte_order);
}
static void
-read_objc_methlist_method (CORE_ADDR addr, unsigned long num,
- struct objc_method *method)
+read_objc_methlist_method (struct gdbarch *gdbarch, CORE_ADDR addr,
+ unsigned long num, struct objc_method *method)
{
- gdb_assert (num < read_objc_methlist_nmethods (addr));
- read_objc_method (addr + 8 + (12 * num), method);
+ gdb_assert (num < read_objc_methlist_nmethods (gdbarch, addr));
+ read_objc_method (gdbarch, addr + 8 + (12 * num), method);
}
static void
-read_objc_object (CORE_ADDR addr, struct objc_object *object)
+read_objc_object (struct gdbarch *gdbarch, CORE_ADDR addr,
+ struct objc_object *object)
{
- object->isa = read_memory_unsigned_integer (addr, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ object->isa = read_memory_unsigned_integer (addr, 4, byte_order);
}
static void
-read_objc_super (CORE_ADDR addr, struct objc_super *super)
+read_objc_super (struct gdbarch *gdbarch, CORE_ADDR addr,
+ struct objc_super *super)
{
- super->receiver = read_memory_unsigned_integer (addr, 4);
- super->class = read_memory_unsigned_integer (addr + 4, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ super->receiver = read_memory_unsigned_integer (addr, 4, byte_order);
+ super->class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
};
static void
-read_objc_class (CORE_ADDR addr, struct objc_class *class)
+read_objc_class (struct gdbarch *gdbarch, CORE_ADDR addr,
+ struct objc_class *class)
{
- class->isa = read_memory_unsigned_integer (addr, 4);
- class->super_class = read_memory_unsigned_integer (addr + 4, 4);
- class->name = read_memory_unsigned_integer (addr + 8, 4);
- class->version = read_memory_unsigned_integer (addr + 12, 4);
- class->info = read_memory_unsigned_integer (addr + 16, 4);
- class->instance_size = read_memory_unsigned_integer (addr + 18, 4);
- class->ivars = read_memory_unsigned_integer (addr + 24, 4);
- class->methods = read_memory_unsigned_integer (addr + 28, 4);
- class->cache = read_memory_unsigned_integer (addr + 32, 4);
- class->protocols = read_memory_unsigned_integer (addr + 36, 4);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ class->isa = read_memory_unsigned_integer (addr, 4, byte_order);
+ class->super_class = read_memory_unsigned_integer (addr + 4, 4, byte_order);
+ class->name = read_memory_unsigned_integer (addr + 8, 4, byte_order);
+ class->version = read_memory_unsigned_integer (addr + 12, 4, byte_order);
+ class->info = read_memory_unsigned_integer (addr + 16, 4, byte_order);
+ class->instance_size = read_memory_unsigned_integer (addr + 18, 4, byte_order);
+ class->ivars = read_memory_unsigned_integer (addr + 24, 4, byte_order);
+ class->methods = read_memory_unsigned_integer (addr + 28, 4, byte_order);
+ class->cache = read_memory_unsigned_integer (addr + 32, 4, byte_order);
+ class->protocols = read_memory_unsigned_integer (addr + 36, 4, byte_order);
}
static CORE_ADDR
-find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
+find_implementation_from_class (struct gdbarch *gdbarch,
+ CORE_ADDR class, CORE_ADDR sel)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR subclass = class;
while (subclass != 0)
struct objc_class class_str;
unsigned mlistnum = 0;
- read_objc_class (subclass, &class_str);
+ read_objc_class (gdbarch, subclass, &class_str);
for (;;)
{
unsigned long i;
mlist = read_memory_unsigned_integer (class_str.methods +
- (4 * mlistnum), 4);
+ (4 * mlistnum),
+ 4, byte_order);
if (mlist == 0)
break;
- nmethods = read_objc_methlist_nmethods (mlist);
+ nmethods = read_objc_methlist_nmethods (gdbarch, mlist);
for (i = 0; i < nmethods; i++)
{
struct objc_method meth_str;
- read_objc_methlist_method (mlist, i, &meth_str);
+ read_objc_methlist_method (gdbarch, mlist, i, &meth_str);
#if 0
fprintf (stderr,
}
static CORE_ADDR
-find_implementation (CORE_ADDR object, CORE_ADDR sel)
+find_implementation (struct gdbarch *gdbarch,
+ CORE_ADDR object, CORE_ADDR sel)
{
struct objc_object ostr;
if (object == 0)
return 0;
- read_objc_object (object, &ostr);
+ read_objc_object (gdbarch, object, &ostr);
if (ostr.isa == 0)
return 0;
- return find_implementation_from_class (ostr.isa, sel);
+ return find_implementation_from_class (gdbarch, ostr.isa, sel);
}
static int
object = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
- res = find_implementation (object, sel);
+ res = find_implementation (gdbarch, object, sel);
if (new_pc != 0)
*new_pc = res;
if (res == 0)
object = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
- res = find_implementation (object, sel);
+ res = find_implementation (gdbarch, object, sel);
if (new_pc != 0)
*new_pc = res;
if (res == 0)
super = gdbarch_fetch_pointer_argument (gdbarch, frame, 0, ptr_type);
sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
- read_objc_super (super, &sstr);
+ read_objc_super (gdbarch, super, &sstr);
if (sstr.class == 0)
return 0;
- res = find_implementation_from_class (sstr.class, sel);
+ res = find_implementation_from_class (gdbarch, sstr.class, sel);
if (new_pc != 0)
*new_pc = res;
if (res == 0)
super = gdbarch_fetch_pointer_argument (gdbarch, frame, 1, ptr_type);
sel = gdbarch_fetch_pointer_argument (gdbarch, frame, 2, ptr_type);
- read_objc_super (super, &sstr);
+ read_objc_super (gdbarch, super, &sstr);
if (sstr.class == 0)
return 0;
- res = find_implementation_from_class (sstr.class, sel);
+ res = find_implementation_from_class (gdbarch, sstr.class, sel);
if (new_pc != 0)
*new_pc = res;
if (res == 0)
int force_ellipses,
const struct value_print_options *options)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
unsigned int i;
unsigned int things_printed = 0;
int in_quotes = 0;
the last byte of it is a null, we don't print that, in traditional C
style. */
if ((!force_ellipses) && length > 0
- && extract_unsigned_integer (string + (length - 1) * width, width) == 0)
+ && extract_unsigned_integer (string + (length - 1) * width, width,
+ byte_order) == 0)
length--;
if (length == 0)
need_comma = 0;
}
- current_char = extract_unsigned_integer (string + i * width, width);
+ current_char = extract_unsigned_integer (string + i * width, width,
+ byte_order);
rep1 = i + 1;
reps = 1;
while (rep1 < length
- && extract_unsigned_integer (string + rep1 * width, width)
- == current_char)
+ && extract_unsigned_integer (string + rep1 * width, width,
+ byte_order) == current_char)
{
++rep1;
++reps;
const struct value_print_options *options)
{
struct gdbarch *gdbarch = get_type_arch (type);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int i = 0; /* Number of characters printed */
unsigned len;
struct type *elttype;
/* Look for a NULL char. */
for (temp_len = 0;
extract_unsigned_integer (valaddr + embedded_offset +
- temp_len * eltlen, eltlen)
+ temp_len * eltlen, eltlen,
+ byte_order)
&& temp_len < len && temp_len < options->print_max;
temp_len++);
len = temp_len;
/* Print vtable entry - we only get here if we ARE using
-fvtable_thunks. (Otherwise, look under TYPE_CODE_STRUCT.) */
/* Extract the address, assume that it is unsigned. */
- print_address_demangle (gdbarch,
- extract_unsigned_integer (valaddr + embedded_offset, TYPE_LENGTH (type)),
- stream, demangle);
+ addr = extract_unsigned_integer (valaddr + embedded_offset,
+ TYPE_LENGTH (type), byte_order);
+ print_address_demangle (gdbarch, addr, stream, demangle);
break;
}
elttype = check_typedef (TYPE_TARGET_TYPE (type));
void *buffer;
buffer = xmalloc (length_size);
read_memory (addr + length_pos, buffer, length_size);
- string_length = extract_unsigned_integer (buffer, length_size);
+ string_length = extract_unsigned_integer (buffer, length_size,
+ byte_order);
xfree (buffer);
i = val_print_string (char_type ,addr + string_pos, string_length, stream, options);
}
print_address_demangle
(gdbarch,
extract_unsigned_integer (valaddr + embedded_offset + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
- TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET))),
+ TYPE_LENGTH (TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET)), byte_order),
stream, demangle);
}
else
if (is_pascal_string_type (type, &length_pos, &length_size,
&string_pos, &char_type, NULL))
{
- len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size);
+ len = extract_unsigned_integer (valaddr + embedded_offset + length_pos, length_size, byte_order);
LA_PRINT_STRING (stream, char_type, valaddr + embedded_offset + string_pos, len, 0, options);
}
else
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
{
int sizeof_auxv_field = ppc_linux_target_wordsize ();
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
gdb_byte *ptr = *readptr;
if (endptr == ptr)
if (endptr - ptr < sizeof_auxv_field * 2)
return -1;
- *typep = extract_unsigned_integer (ptr, sizeof_auxv_field);
+ *typep = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
ptr += sizeof_auxv_field;
- *valp = extract_unsigned_integer (ptr, sizeof_auxv_field);
+ *valp = extract_unsigned_integer (ptr, sizeof_auxv_field, byte_order);
ptr += sizeof_auxv_field;
*readptr = ptr;
/* If DESC is the address of a 64-bit PowerPC GNU/Linux function
descriptor, return the descriptor's entry point. */
static CORE_ADDR
-ppc64_desc_entry_point (CORE_ADDR desc)
+ppc64_desc_entry_point (struct gdbarch *gdbarch, CORE_ADDR desc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* The first word of the descriptor is the entry point. */
- return (CORE_ADDR) read_memory_unsigned_integer (desc, 8);
+ return (CORE_ADDR) read_memory_unsigned_integer (desc, 8, byte_order);
}
ppc64_standard_linkage1_target (struct frame_info *frame,
CORE_ADDR pc, unsigned int *insn)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* The address of the function descriptor this linkage function
references. */
+ insn_ds_field (insn[2]));
/* The first word of the descriptor is the entry point. Return that. */
- return ppc64_desc_entry_point (desc);
+ return ppc64_desc_entry_point (gdbarch, desc);
}
static struct core_regset_section ppc_linux_vsx_regset_sections[] =
ppc64_standard_linkage2_target (struct frame_info *frame,
CORE_ADDR pc, unsigned int *insn)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* The address of the function descriptor this linkage function
references. */
+ insn_ds_field (insn[2]));
/* The first word of the descriptor is the entry point. Return that. */
- return ppc64_desc_entry_point (desc);
+ return ppc64_desc_entry_point (gdbarch, desc);
}
static CORE_ADDR
ppc64_standard_linkage3_target (struct frame_info *frame,
CORE_ADDR pc, unsigned int *insn)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
/* The address of the function descriptor this linkage function
references. */
+ insn_ds_field (insn[1]));
/* The first word of the descriptor is the entry point. Return that. */
- return ppc64_desc_entry_point (desc);
+ return ppc64_desc_entry_point (gdbarch, desc);
}
CORE_ADDR addr,
struct target_ops *targ)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct target_section *s = target_section_by_addr (targ, addr);
/* Check if ADDR points to a function descriptor. */
res = bfd_get_section_contents (s->bfd, s->the_bfd_section,
&buf, addr - s->addr, 8);
if (res != 0)
- return extract_unsigned_integer (buf, 8)
+ return extract_unsigned_integer (buf, 8, byte_order)
- bfd_section_vma (s->bfd, s->the_bfd_section) + s->addr;
}
int i;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
base = get_frame_register_unsigned (this_frame,
gdbarch_sp_regnum (gdbarch));
regs = base + offset;
/* Use that to find the address of the corresponding register
buffers. */
- gpregs = read_memory_unsigned_integer (regs, tdep->wordsize);
+ gpregs = read_memory_unsigned_integer (regs, tdep->wordsize, byte_order);
fpregs = gpregs + 48 * tdep->wordsize;
/* General purpose. */
int struct_return, CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST saved_sp;
int argspace = 0; /* 0 is an initial wrong guess. */
int write_pass;
write_memory (sp + structoffset, val, len);
/* ... and then a "word" pointing to that address is
passed as the parameter. */
- store_unsigned_integer (word, tdep->wordsize,
+ store_unsigned_integer (word, tdep->wordsize, byte_order,
sp + structoffset);
structoffset += len;
}
else if (TYPE_CODE (type) == TYPE_CODE_INT)
/* Sign or zero extend the "int" into a "word". */
- store_unsigned_integer (word, tdep->wordsize,
+ store_unsigned_integer (word, tdep->wordsize, byte_order,
unpack_long (type, val));
else
/* Always goes in the low address. */
regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
/* Write the backchain (it occupies WORDSIZED bytes). */
- write_memory_signed_integer (sp, tdep->wordsize, saved_sp);
+ write_memory_signed_integer (sp, tdep->wordsize, byte_order, saved_sp);
/* Point the inferior function call's return address at the dummy's
breakpoint. */
const gdb_byte *writebuf, int broken_gcc)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_assert (tdep->wordsize == 4);
if (TYPE_CODE (type) == TYPE_CODE_FLT
&& TYPE_LENGTH (type) <= 8
ULONGEST regval;
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
®val);
- store_unsigned_integer (readbuf, TYPE_LENGTH (type), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (type), byte_order,
+ regval);
}
if (writebuf)
{
{
CORE_ADDR func_addr = find_function_addr (function, NULL);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST back_chain;
/* See for-loop comment below. */
int write_pass;
tdep->ppc_gp0_regnum +
greg, word);
write_memory_unsigned_integer (gparam, tdep->wordsize,
- word);
+ byte_order, word);
}
greg++;
gparam = align_up (gparam + TYPE_LENGTH (type), tdep->wordsize);
regcache_cooked_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
/* Write the backchain (it occupies WORDSIZED bytes). */
- write_memory_signed_integer (sp, tdep->wordsize, back_chain);
+ write_memory_signed_integer (sp, tdep->wordsize, byte_order, back_chain);
/* Point the inferior function call's return address at the dummy's
breakpoint. */
/* The TOC is the second double word in the descriptor. */
CORE_ADDR toc =
read_memory_unsigned_integer (desc_addr + tdep->wordsize,
- tdep->wordsize);
+ tdep->wordsize, byte_order);
regcache_cooked_write_unsigned (regcache,
tdep->ppc_gp0_regnum + 2, toc);
}
gdb_byte *readbuf, const gdb_byte *writebuf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* This function exists to support a calling convention that
requires floating-point registers. It shouldn't be used on
ULONGEST regval;
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
®val);
- store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+ regval);
}
return RETURN_VALUE_REGISTER_CONVENTION;
}
struct frame_info *this_frame,
void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc = get_frame_pc (this_frame);
CORE_ADDR start_pc = (pc & ~(ppcobsd_page_size - 1));
const int *offset;
continue;
/* Check for "li r0,SYS_sigreturn". */
- insn = extract_unsigned_integer (buf, PPC_INSN_SIZE);
+ insn = extract_unsigned_integer (buf, PPC_INSN_SIZE, byte_order);
if (insn != 0x38000067)
continue;
/* Check for "sc". */
- insn = extract_unsigned_integer (buf + PPC_INSN_SIZE, PPC_INSN_SIZE);
+ insn = extract_unsigned_integer (buf + PPC_INSN_SIZE,
+ PPC_INSN_SIZE, byte_order);
if (insn != 0x44000002)
continue;
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct trad_frame_cache *cache;
CORE_ADDR addr, base, func;
gdb_byte buf[PPC_INSN_SIZE];
/* Calculate the offset where we can find `struct sigcontext'. We
base our calculation on the amount of stack space reserved by the
first instruction of the signal trampoline. */
- insn = extract_unsigned_integer (buf, PPC_INSN_SIZE);
+ insn = extract_unsigned_integer (buf, PPC_INSN_SIZE, byte_order);
sigcontext_offset = (0x10000 - (insn & 0x0000ffff)) + 8;
base = get_frame_register_unsigned (this_frame, gdbarch_sp_regnum (gdbarch));
int j;
struct gdbarch *gdbarch
= get_type_arch (value_type (val_args[i]));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *wctype = lookup_typename (current_language, gdbarch,
"wchar_t", NULL, 0);
int wcwidth = TYPE_LENGTH (wctype);
{
QUIT;
read_memory (tem + j, buf, wcwidth);
- if (extract_unsigned_integer (buf, wcwidth) == 0)
+ if (extract_unsigned_integer (buf, wcwidth, byte_order) == 0)
break;
}
obstack_init (&output);
inner_cleanup = make_cleanup_obstack_free (&output);
- convert_between_encodings (target_wide_charset (),
+ convert_between_encodings (target_wide_charset (byte_order),
host_charset (),
str, j, wcwidth,
&output, translit_char);
{
struct gdbarch *gdbarch
= get_type_arch (value_type (val_args[i]));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *wctype = lookup_typename (current_language, gdbarch,
"wchar_t", NULL, 0);
struct type *valtype;
obstack_init (&output);
inner_cleanup = make_cleanup_obstack_free (&output);
- convert_between_encodings (target_wide_charset (),
+ convert_between_encodings (target_wide_charset (byte_order),
host_charset (),
bytes, TYPE_LENGTH (valtype),
TYPE_LENGTH (valtype),
struct type *param_type = value_type (val_args[i]);
unsigned int param_len = TYPE_LENGTH (param_type);
struct gdbarch *gdbarch = get_type_arch (param_type);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* DFP output data. */
struct value *dfp_value = NULL;
/* Conversion between different DFP types. */
if (TYPE_CODE (param_type) == TYPE_CODE_DECFLOAT)
- decimal_convert (param_ptr, param_len, dec, dfp_len);
+ decimal_convert (param_ptr, param_len, byte_order,
+ dec, dfp_len, byte_order);
else
/* If this is a non-trivial conversion, just output 0.
A correct converted value can be displayed by explicitly
casting to a DFP type. */
- decimal_from_string (dec, dfp_len, "0");
+ decimal_from_string (dec, dfp_len, byte_order, "0");
dfp_value = value_from_decfloat (dfp_type, dec);
dfp_ptr = (gdb_byte *) value_contents (dfp_value);
- decimal_to_string (dfp_ptr, dfp_len, decstr);
+ decimal_to_string (dfp_ptr, dfp_len, byte_order, decstr);
/* Print the DFP value. */
printf_filtered (current_substring, decstr);
procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
gdb_byte *endptr, CORE_ADDR *typep, CORE_ADDR *valp)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
gdb_byte *ptr = *readptr;
if (endptr == ptr)
if (endptr - ptr < 8 * 2)
return -1;
- *typep = extract_unsigned_integer (ptr, 4);
+ *typep = extract_unsigned_integer (ptr, 4, byte_order);
ptr += 8;
/* The size of data is always 64-bit. If the application is 32-bit,
it will be zero extended, as expected. */
- *valp = extract_unsigned_integer (ptr, 8);
+ *valp = extract_unsigned_integer (ptr, 8, byte_order);
ptr += 8;
*readptr = ptr;
return value_as_double (self_value->value) != 0;
else if (TYPE_CODE (type) == TYPE_CODE_DECFLOAT)
return !decimal_is_zero (value_contents (self_value->value),
- TYPE_LENGTH (type));
+ TYPE_LENGTH (type),
+ gdbarch_byte_order (get_type_arch (type)));
else
{
PyErr_SetString (PyExc_TypeError, _("Attempted truth testing on invalid "
gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
regcache_raw_read (regcache, regnum, buf);
- (*val) = extract_signed_integer (buf,
- regcache->descr->sizeof_register[regnum]);
+ (*val) = extract_signed_integer
+ (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch));
}
void
gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_raw_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
regcache_raw_read (regcache, regnum, buf);
- (*val) = extract_unsigned_integer (buf,
- regcache->descr->sizeof_register[regnum]);
+ (*val) = extract_unsigned_integer
+ (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch));
}
void
gdb_assert (regcache != NULL);
gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
- store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
+ store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
regcache_raw_write (regcache, regnum, buf);
}
gdb_assert (regcache != NULL);
gdb_assert (regnum >=0 && regnum < regcache->descr->nr_raw_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
- store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
+ store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
regcache_raw_write (regcache, regnum, buf);
}
gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
regcache_cooked_read (regcache, regnum, buf);
- (*val) = extract_signed_integer (buf,
- regcache->descr->sizeof_register[regnum]);
+ (*val) = extract_signed_integer
+ (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch));
}
void
gdb_assert (regnum >= 0 && regnum < regcache->descr->nr_cooked_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
regcache_cooked_read (regcache, regnum, buf);
- (*val) = extract_unsigned_integer (buf,
- regcache->descr->sizeof_register[regnum]);
+ (*val) = extract_unsigned_integer
+ (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch));
}
void
gdb_assert (regcache != NULL);
gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
- store_signed_integer (buf, regcache->descr->sizeof_register[regnum], val);
+ store_signed_integer (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
regcache_cooked_write (regcache, regnum, buf);
}
gdb_assert (regcache != NULL);
gdb_assert (regnum >=0 && regnum < regcache->descr->nr_cooked_registers);
buf = alloca (regcache->descr->sizeof_register[regnum]);
- store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum], val);
+ store_unsigned_integer (buf, regcache->descr->sizeof_register[regnum],
+ gdbarch_byte_order (regcache->descr->gdbarch), val);
regcache_cooked_write (regcache, regnum, buf);
}
m32r_fetch_register (struct target_ops *ops,
struct regcache *regcache, int regno)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned long val, val2, regid;
if (regno == -1)
/* We got the number the register holds, but gdb expects to see a
value in the target byte ordering. */
- store_unsigned_integer (buffer, 4, val);
+ store_unsigned_integer (buffer, 4, byte_order, val);
regcache_raw_supply (regcache, regno, buffer);
}
return;
static unsigned int mips_fetch_word (CORE_ADDR addr);
static int mips_store_word (CORE_ADDR addr, unsigned int value,
- char *old_contents);
+ int *old_contents);
static int mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
int write,
{
struct regcache *regcache = get_current_regcache ();
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[MAX_REGISTER_SIZE];
- store_unsigned_integer (buf,
- register_size
- (gdbarch, gdbarch_pc_regnum (gdbarch)), rpc);
+ store_unsigned_integer
+ (buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)),
+ byte_order, rpc);
regcache_raw_supply (regcache, gdbarch_pc_regnum (gdbarch), buf);
store_unsigned_integer
- (buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)), rfp);
+ (buf, register_size (gdbarch, gdbarch_pc_regnum (gdbarch)),
+ byte_order, rfp);
regcache_raw_supply (regcache, 30, buf); /* This register they are avoiding and so it is unnamed */
- store_unsigned_integer (buf, register_size (gdbarch,
- gdbarch_sp_regnum (gdbarch)), rsp);
+ store_unsigned_integer
+ (buf, register_size (gdbarch, gdbarch_sp_regnum (gdbarch)),
+ byte_order, rsp);
regcache_raw_supply (regcache, gdbarch_sp_regnum (gdbarch), buf);
- store_unsigned_integer (buf,
- register_size (gdbarch,
- gdbarch_deprecated_fp_regnum
- (gdbarch)),
- 0);
+ store_unsigned_integer
+ (buf, register_size (gdbarch, gdbarch_deprecated_fp_regnum (gdbarch)),
+ byte_order, 0);
regcache_raw_supply (regcache,
gdbarch_deprecated_fp_regnum (gdbarch), buf);
struct regcache *regcache, int regno)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned LONGEST val;
int err;
/* We got the number the register holds, but gdb expects to see a
value in the target byte ordering. */
- store_unsigned_integer (buf, register_size (gdbarch, regno), val);
+ store_unsigned_integer (buf, register_size (gdbarch, regno),
+ byte_order, val);
regcache_raw_supply (regcache, regno, buf);
}
}
/* FIXME! make sure only 32-bit quantities get stored! */
static int
-mips_store_word (CORE_ADDR addr, unsigned int val, char *old_contents)
+mips_store_word (CORE_ADDR addr, unsigned int val, int *old_contents)
{
int err;
unsigned int oldcontents;
return errno;
}
if (old_contents != NULL)
- store_unsigned_integer (old_contents, 4, oldcontents);
+ *old_contents = oldcontents;
return 0;
}
mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
struct mem_attrib *attrib, struct target_ops *target)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int i;
CORE_ADDR addr;
int count;
if (addr != memaddr || len < 4)
{
/* Need part of initial word -- fetch it. */
- store_unsigned_integer (&buffer[0], 4, mips_fetch_word (addr));
+ store_unsigned_integer (&buffer[0], 4, byte_order,
+ mips_fetch_word (addr));
}
if (count > 1)
{
/* Need part of last word -- fetch it. FIXME: we do this even
if we don't need it. */
- store_unsigned_integer (&buffer[(count - 1) * 4], 4,
+ store_unsigned_integer (&buffer[(count - 1) * 4], 4, byte_order,
mips_fetch_word (addr + (count - 1) * 4));
}
for (i = 0; i < count; i++, addr += 4)
{
- status = mips_store_word (addr,
- extract_unsigned_integer (&buffer[i * 4], 4),
- NULL);
+ int word;
+ word = extract_unsigned_integer (&buffer[i * 4], 4, byte_order);
+ status = mips_store_word (addr, word, NULL);
/* Report each kilobyte (we download 32-bit words at a time) */
if (i % 256 == 255)
{
/* Read all the longwords */
for (i = 0; i < count; i++, addr += 4)
{
- store_unsigned_integer (&buffer[i * 4], 4, mips_fetch_word (addr));
+ store_unsigned_integer (&buffer[i * 4], 4, byte_order,
+ mips_fetch_word (addr));
QUIT;
}
int struct_return, CORE_ADDR struct_addr)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int ii;
int len = 0;
int argno; /* current argument number */
regcache_raw_write_signed (regcache, gdbarch_sp_regnum (gdbarch), sp);
/* Set back chain properly. */
- store_unsigned_integer (tmp_buffer, wordsize, saved_sp);
+ store_unsigned_integer (tmp_buffer, wordsize, byte_order, saved_sp);
write_memory (sp, tmp_buffer, wordsize);
/* Point the inferior function call's return address at the dummy's
gdb_byte *readbuf, const gdb_byte *writebuf)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[8];
/* The calling convention this function implements assumes the
/* For reading we don't have to worry about sign extension. */
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
®val);
- store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+ regval);
}
if (writebuf)
{
CORE_ADDR addr,
struct target_ops *targ)
{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *s;
s = find_pc_section (addr);
if (s && (s->the_bfd_section->flags & SEC_CODE) == 0)
{
CORE_ADDR pc =
- read_memory_unsigned_integer (addr, gdbarch_tdep (gdbarch)->wordsize);
+ read_memory_unsigned_integer (addr, tdep->wordsize, byte_order);
struct obj_section *pc_section = find_pc_section (pc);
if (pc_section && (pc_section->the_bfd_section->flags & SEC_CODE))
branch_dest (struct frame_info *frame, int opcode, int instr,
CORE_ADDR pc, CORE_ADDR safety)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR dest;
int immediate;
int absolute;
if (dest < AIX_TEXT_SEGMENT_BASE)
dest = read_memory_unsigned_integer
(get_frame_base (frame) + SIG_FRAME_PC_OFFSET,
- tdep->wordsize);
+ tdep->wordsize, byte_order);
}
else if (ext_op == 528) /* br cond to count reg */
rs6000_software_single_step (struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int ii, insn;
CORE_ADDR loc;
CORE_ADDR breaks[2];
loc = get_frame_pc (frame);
- insn = read_memory_integer (loc, 4);
+ insn = read_memory_integer (loc, 4, byte_order);
if (ppc_deal_with_atomic_sequence (frame))
return 1;
rs6000_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
bfd_byte insn_buf[PPC_INSN_SIZE];
CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end;
unsigned long insn;
{
if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE))
return 0;
- insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE);
+ insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order);
if (insn == 0x4e800020)
break;
/* Assume a bctr is a tail call unless it points strictly within
{
if (!safe_frame_unwind_memory (curfrm, scan_pc, insn_buf, PPC_INSN_SIZE))
return 0;
- insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE);
+ insn = extract_unsigned_integer (insn_buf, PPC_INSN_SIZE, byte_order);
if (insn_changes_sp_or_jumps (insn))
return 1;
}
CORE_ADDR from, CORE_ADDR to,
struct regcache *regs)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Since we use simple_displaced_step_copy_insn, our closure is a
copy of the instruction. */
ULONGEST insn = extract_unsigned_integer ((gdb_byte *) closure,
- PPC_INSN_SIZE);
+ PPC_INSN_SIZE, byte_order);
ULONGEST opcode = 0;
/* Offset for non PC-relative instructions. */
LONGEST offset = PPC_INSN_SIZE;
ppc_deal_with_atomic_sequence (struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc = get_frame_pc (frame);
CORE_ADDR breaks[2] = {-1, -1};
CORE_ADDR loc = pc;
CORE_ADDR closing_insn; /* Instruction that closes the atomic sequence. */
- int insn = read_memory_integer (loc, PPC_INSN_SIZE);
+ int insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
int insn_count;
int index;
int last_breakpoint = 0; /* Defaults to 0 (no breakpoints placed). */
for (insn_count = 0; insn_count < atomic_sequence_length; ++insn_count)
{
loc += PPC_INSN_SIZE;
- insn = read_memory_integer (loc, PPC_INSN_SIZE);
+ insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
/* Assume that there is at most one conditional branch in the atomic
sequence. If a conditional branch is found, put a breakpoint in
closing_insn = loc;
loc += PPC_INSN_SIZE;
- insn = read_memory_integer (loc, PPC_INSN_SIZE);
+ insn = read_memory_integer (loc, PPC_INSN_SIZE, byte_order);
/* Insert a breakpoint right after the end of the atomic sequence. */
breaks[0] = loc;
they can use to access PIC data using PC-relative offsets. */
static int
-bl_to_blrl_insn_p (CORE_ADDR pc, int insn)
+bl_to_blrl_insn_p (CORE_ADDR pc, int insn, enum bfd_endian byte_order)
{
CORE_ADDR dest;
int immediate;
else
dest = pc + immediate;
- dest_insn = read_memory_integer (dest, 4);
+ dest_insn = read_memory_integer (dest, 4, byte_order);
if ((dest_insn & 0xfc00ffff) == 0x4c000021) /* blrl */
return 1;
#define BL_DISPLACEMENT_MASK 0x03fffffc
static unsigned long
-rs6000_fetch_instruction (const CORE_ADDR pc)
+rs6000_fetch_instruction (struct gdbarch *gdbarch, const CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
unsigned long op;
/* Fetch the instruction and convert it to an integer. */
if (target_read_memory (pc, buf, 4))
return 0;
- op = extract_unsigned_integer (buf, 4);
+ op = extract_unsigned_integer (buf, 4, byte_order);
return op;
}
instruction immediately past this sequence. Otherwise, return START_PC. */
static CORE_ADDR
-rs6000_skip_stack_check (const CORE_ADDR start_pc)
+rs6000_skip_stack_check (struct gdbarch *gdbarch, const CORE_ADDR start_pc)
{
CORE_ADDR pc = start_pc;
- unsigned long op = rs6000_fetch_instruction (pc);
+ unsigned long op = rs6000_fetch_instruction (gdbarch, pc);
/* First possible sequence: A small number of probes.
stw 0, -<some immediate>(1)
while ((op & 0xffff0000) == 0x90010000)
{
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
}
return pc;
}
/* lis 0,-<some immediate> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) != 0x3c000000)
break;
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
/* [possibly ori 0,0,<some immediate>] */
if ((op & 0xffff0000) == 0x60000000)
{
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
}
/* add 0,12,0 */
if (op != 0x7c0c0214)
/* cmpw 0,12,0 */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if (op != 0x7c0c0000)
break;
/* beq 0,<disp> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xff9f0001) != 0x41820000)
break;
/* addi 12,12,-<some immediate> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) != 0x398c0000)
break;
/* stw 0,0(12) */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if (op != 0x900c0000)
break;
/* b <disp> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xfc000001) != 0x48000000)
break;
/* [possibly one last probe: stw 0,<some immediate>(12)] */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) == 0x900c0000)
{
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
}
/* We found a valid stack-check sequence, return the new PC. */
/* addic 0,0,-<some immediate> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) != 0x30000000)
break;
}
/* lis 12,<some immediate> */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) != 0x3d800000)
break;
/* lwz 12,<some immediate>(12) */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xffff0000) != 0x818c0000)
break;
/* twllt 0,12 */
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
if ((op & 0xfffffffe) != 0x7c406008)
break;
int r0_contains_arg = 0;
const struct bfd_arch_info *arch_info = gdbarch_bfd_arch_info (gdbarch);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
memset (fdata, 0, sizeof (struct rs6000_framedata));
fdata->saved_gpr = -1;
fdata->nosavedpc = 1;
fdata->lr_register = -1;
- pc = rs6000_skip_stack_check (pc);
+ pc = rs6000_skip_stack_check (gdbarch, pc);
if (pc >= lim_pc)
pc = lim_pc;
/* Fetch the instruction and convert it to an integer. */
if (target_read_memory (pc, buf, 4))
break;
- op = extract_unsigned_integer (buf, 4);
+ op = extract_unsigned_integer (buf, 4, byte_order);
if ((op & 0xfc1fffff) == 0x7c0802a6)
{ /* mflr Rx */
/* If the return address has already been saved, we can skip
calls to blrl (for PIC). */
- if (lr_reg != -1 && bl_to_blrl_insn_p (pc, op))
+ if (lr_reg != -1 && bl_to_blrl_insn_p (pc, op, byte_order))
{
fdata->used_bl = 1;
continue;
break;
}
- op = read_memory_integer (pc + 4, 4);
+ op = read_memory_integer (pc + 4, 4, byte_order);
/* At this point, make sure this is not a trampoline
function (a function that simply calls another functions,
if ((op & 0xfc000001) == 0x48000001)
{ /* bl foo, an initializer function? */
- op = read_memory_integer (pc + 4, 4);
+ op = read_memory_integer (pc + 4, 4, byte_order);
if (op == 0x4def7b82)
{ /* cror 0xf, 0xf, 0xf (nop) */
static CORE_ADDR
rs6000_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
unsigned long op;
if (target_read_memory (pc, buf, 4))
return pc;
- op = extract_unsigned_integer (buf, 4);
+ op = extract_unsigned_integer (buf, 4, byte_order);
if ((op & BL_MASK) == BL_INSTRUCTION)
{
@FIX code. */
static int
-rs6000_in_solib_return_trampoline (CORE_ADDR pc, char *name)
+rs6000_in_solib_return_trampoline (struct gdbarch *gdbarch,
+ CORE_ADDR pc, char *name)
{
return name && !strncmp (name, "@FIX", 4);
}
static CORE_ADDR
rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
- struct gdbarch_tdep *tdep = gdbarch_tdep (get_frame_arch (frame));
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int ii, op;
int rel;
CORE_ADDR solib_target_pc;
/* Check for bigtoc fixup code. */
msymbol = lookup_minimal_symbol_by_pc (pc);
if (msymbol
- && rs6000_in_solib_return_trampoline (pc, SYMBOL_LINKAGE_NAME (msymbol)))
+ && rs6000_in_solib_return_trampoline (gdbarch, pc,
+ SYMBOL_LINKAGE_NAME (msymbol)))
{
/* Double-check that the third instruction from PC is relative "b". */
- op = read_memory_integer (pc + 8, 4);
+ op = read_memory_integer (pc + 8, 4, byte_order);
if ((op & 0xfc000003) == 0x48000000)
{
/* Extract bits 6-29 as a signed 24-bit relative word address and
for (ii = 0; trampoline_code[ii]; ++ii)
{
- op = read_memory_integer (pc + (ii * 4), 4);
+ op = read_memory_integer (pc + (ii * 4), 4, byte_order);
if (op != trampoline_code[ii])
return 0;
}
ii = get_frame_register_unsigned (frame, 11); /* r11 holds destination addr */
- pc = read_memory_unsigned_integer (ii, tdep->wordsize); /* (r11) value */
+ pc = read_memory_unsigned_integer (ii, tdep->wordsize, byte_order);
return pc;
}
struct rs6000_frame_cache *cache;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct rs6000_framedata fdata;
int wordsize = tdep->wordsize;
CORE_ADDR func, pc;
if (!fdata.frameless)
/* Frameless really means stackless. */
- cache->base = read_memory_unsigned_integer (cache->base, wordsize);
+ cache->base
+ = read_memory_unsigned_integer (cache->base, wordsize, byte_order);
trad_frame_set_value (cache->saved_regs,
gdbarch_sp_regnum (gdbarch), cache->base);
s390_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
switch (regnum)
{
case S390_PC_REGNUM:
regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &val);
- store_unsigned_integer (buf, 4, val & 0x7fffffff);
+ store_unsigned_integer (buf, 4, byte_order, val & 0x7fffffff);
break;
case S390_CC_REGNUM:
regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val);
- store_unsigned_integer (buf, 4, (val >> 12) & 3);
+ store_unsigned_integer (buf, 4, byte_order, (val >> 12) & 3);
break;
default:
s390_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val, psw;
switch (regnum)
{
case S390_PC_REGNUM:
- val = extract_unsigned_integer (buf, 4);
+ val = extract_unsigned_integer (buf, 4, byte_order);
regcache_raw_read_unsigned (regcache, S390_PSWA_REGNUM, &psw);
psw = (psw & 0x80000000) | (val & 0x7fffffff);
regcache_raw_write_unsigned (regcache, S390_PSWA_REGNUM, psw);
break;
case S390_CC_REGNUM:
- val = extract_unsigned_integer (buf, 4);
+ val = extract_unsigned_integer (buf, 4, byte_order);
regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
psw = (psw & ~((ULONGEST)3 << 12)) | ((val & 3) << 12);
regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, psw);
s390x_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
switch (regnum)
case S390_CC_REGNUM:
regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &val);
- store_unsigned_integer (buf, 4, (val >> 44) & 3);
+ store_unsigned_integer (buf, 4, byte_order, (val >> 44) & 3);
break;
default:
s390x_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val, psw;
switch (regnum)
break;
case S390_CC_REGNUM:
- val = extract_unsigned_integer (buf, 4);
+ val = extract_unsigned_integer (buf, 4, byte_order);
regcache_raw_read_unsigned (regcache, S390_PSWM_REGNUM, &psw);
psw = (psw & ~((ULONGEST)3 << 44)) | ((val & 3) << 44);
regcache_raw_write_unsigned (regcache, S390_PSWM_REGNUM, psw);
/* The stack. */
struct pv_area *stack;
- /* The size of a GPR or FPR. */
+ /* The size and byte-order of a GPR or FPR. */
int gpr_size;
int fpr_size;
+ enum bfd_endian byte_order;
/* The general-purpose registers. */
pv_t gpr[S390_NUM_GPRS];
if (secp != NULL
&& (bfd_get_section_flags (secp->bfd, secp->the_bfd_section)
& SEC_READONLY))
- return pv_constant (read_memory_integer (addr.k, size));
+ return pv_constant (read_memory_integer (addr.k, size,
+ data->byte_order));
}
/* Check whether we are accessing one of our save slots. */
(i.e. when running a 32-bit binary under a 64-bit kernel). */
data->gpr_size = word_size;
data->fpr_size = 8;
+ data->byte_order = gdbarch_byte_order (gdbarch);
for (i = 0; i < S390_NUM_GPRS; i++)
data->gpr[i] = pv_register (S390_R0_REGNUM + i, 0);
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR backchain;
ULONGEST reg;
LONGEST sp;
/* Get the backchain. */
reg = get_frame_register_unsigned (this_frame, S390_SP_REGNUM);
- backchain = read_memory_unsigned_integer (reg, word_size);
+ backchain = read_memory_unsigned_integer (reg, word_size, byte_order);
/* A zero backchain terminates the frame chain. As additional
sanity check, let's verify that the spill slot for SP in the
save area pointed to by the backchain in fact links back to
the save area. */
if (backchain != 0
- && safe_read_memory_integer (backchain + 15*word_size, word_size, &sp)
+ && safe_read_memory_integer (backchain + 15*word_size,
+ word_size, byte_order, &sp)
&& (CORE_ADDR)sp == backchain)
{
/* We don't know which registers were saved, but it will have
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct s390_sigtramp_unwind_cache *info;
ULONGEST this_sp, prev_sp;
CORE_ADDR next_ra, next_cfa, sigreg_ptr;
pointer to sigregs */
else
{
- sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8, word_size);
+ sigreg_ptr = read_memory_unsigned_integer (next_cfa + 8,
+ word_size, byte_order);
}
/* The sigregs structure looks like this:
/* Restore the previous frame's SP. */
prev_sp = read_memory_unsigned_integer (
info->saved_regs[S390_SP_REGNUM].addr,
- word_size);
+ word_size, byte_order);
/* Determine our frame base. */
info->frame_base = prev_sp + 16*word_size + 32;
/* Return ARG, a `SIMPLE_ARG', sign-extended or zero-extended to a full
word as required for the ABI. */
static LONGEST
-extend_simple_arg (struct value *arg)
+extend_simple_arg (struct gdbarch *gdbarch, struct value *arg)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct type *type = value_type (arg);
/* Even structs get passed in the least significant bits of the
an integer, but it does take care of the extension. */
if (TYPE_UNSIGNED (type))
return extract_unsigned_integer (value_contents (arg),
- TYPE_LENGTH (type));
+ TYPE_LENGTH (type), byte_order);
else
return extract_signed_integer (value_contents (arg),
- TYPE_LENGTH (type));
+ TYPE_LENGTH (type), byte_order);
}
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST orig_sp;
int i;
}
else
{
- write_memory_unsigned_integer (starg, word_size, copy_addr[i]);
+ write_memory_unsigned_integer (starg, word_size, byte_order,
+ copy_addr[i]);
starg += word_size;
}
}
{
/* Integer arguments are always extended to word size. */
regcache_cooked_write_signed (regcache, S390_R0_REGNUM + gr,
- extend_simple_arg (arg));
+ extend_simple_arg (gdbarch, arg));
gr++;
}
else
{
/* Integer arguments are always extended to word size. */
- write_memory_signed_integer (starg, word_size,
- extend_simple_arg (arg));
+ write_memory_signed_integer (starg, word_size, byte_order,
+ extend_simple_arg (gdbarch, arg));
starg += word_size;
}
}
struct type *type, struct regcache *regcache,
gdb_byte *out, const gdb_byte *in)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int word_size = gdbarch_ptr_bit (gdbarch) / 8;
int length = TYPE_LENGTH (type);
enum return_value_convention rvc =
/* Integer arguments are always extended to word size. */
if (TYPE_UNSIGNED (type))
regcache_cooked_write_unsigned (regcache, S390_R2_REGNUM,
- extract_unsigned_integer (in, length));
+ extract_unsigned_integer (in, length, byte_order));
else
regcache_cooked_write_signed (regcache, S390_R2_REGNUM,
- extract_signed_integer (in, length));
+ extract_signed_integer (in, length, byte_order));
}
else if (length == 2*word_size)
{
if (!is_scmvalue_type (value_type (val)))
error ("quoted scm form yields non-SCM value");
svalue = extract_signed_integer (value_contents (val),
- TYPE_LENGTH (value_type (val)));
+ TYPE_LENGTH (value_type (val)),
+ gdbarch_byte_order (parse_gdbarch));
goto handle_immediate;
}
return;
of the 0'th one. */
LONGEST
-scm_get_field (LONGEST svalue, int index, int size)
+scm_get_field (LONGEST svalue, int index, int size,
+ enum bfd_endian byte_order)
{
gdb_byte buffer[20];
read_memory (SCM2PTR (svalue) + index * size, buffer, size);
- return extract_signed_integer (buffer, size);
+ return extract_signed_integer (buffer, size, byte_order);
}
/* Unpack a value of type TYPE in buffer VALADDR as an integer
{
if (is_scmvalue_type (type))
{
- LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+ LONGEST svalue
+ = extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
+
if (context == TYPE_CODE_BOOL)
{
if (svalue == SCM_BOOL_F)
#define SCM_LENGTH(x) (((unsigned long)SCM_CAR(x))>>8)
#define SCM_NCONSP(x) (1 & (int)SCM_CAR(x))
#define SCM_NECONSP(x) (SCM_NCONSP(x) && (1 != SCM_TYP3(x)))
-#define SCM_CAR(x) scm_get_field (x, 0, SCM_SIZE)
-#define SCM_CDR(x) scm_get_field (x, 1, SCM_SIZE)
+#define SCM_CAR(x) scm_get_field (x, 0, SCM_SIZE, SCM_BYTE_ORDER)
+#define SCM_CDR(x) scm_get_field (x, 1, SCM_SIZE, SCM_BYTE_ORDER)
#define SCM_VELTS(x) ((SCM *)SCM_CDR(x))
#define SCM_CLOSCAR(x) (SCM_CAR(x)-scm_tc3_closure)
#define SCM_CODE(x) SCM_CAR(SCM_CLOSCAR (x))
struct ui_file *, int,
const struct value_print_options *);
-extern LONGEST scm_get_field (LONGEST, int, int);
+extern LONGEST scm_get_field (LONGEST, int, int, enum bfd_endian);
extern int is_scmvalue_type (struct type *);
const struct value_print_options *options)
{
#define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (get_type_arch (type)))
unsigned int more = options->print_max;
if (recurse > 6)
{
fputs_filtered (" . ", stream);
scm_scmval_print (type, svalue, stream, recurse + 1, options);
}
+#undef SCM_BYTE_ORDER
#undef SCM_SIZE
}
struct ui_file *stream)
{
#define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (get_type_arch (type)))
fprintf_filtered (stream, "#<unknown-%s", hdr);
if (SCM_CELLP (ptr))
fprintf_filtered (stream, " (0x%lx . 0x%lx) @",
(long) SCM_CAR (ptr), (long) SCM_CDR (ptr));
fprintf_filtered (stream, " 0x%s>", phex_nz (ptr, SCM_SIZE));
+#undef SCM_BYTE_ORDER
#undef SCM_SIZE
}
struct gdbarch *gdbarch = get_type_arch (type);
#define SCM_SIZE (TYPE_LENGTH (type))
+#define SCM_BYTE_ORDER (gdbarch_byte_order (gdbarch))
taloop:
switch (7 & (int) svalue)
{
int len = SCM_LENGTH (svalue);
int i;
LONGEST elements = SCM_CDR (svalue);
+ LONGEST val;
fputs_filtered ("#(", stream);
for (i = 0; i < len; ++i)
{
if (i > 0)
fputs_filtered (" ", stream);
- scm_scmval_print (type, scm_get_field (elements, i, SCM_SIZE),
- stream, recurse + 1, options);
+ val = scm_get_field (elements, i, SCM_SIZE, SCM_BYTE_ORDER);
+ scm_scmval_print (type, val, stream, recurse + 1, options);
}
fputs_filtered (")", stream);
}
}
break;
}
+#undef SCM_BYTE_ORDER
#undef SCM_SIZE
}
{
if (is_scmvalue_type (type))
{
- LONGEST svalue = extract_signed_integer (valaddr, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
+ LONGEST svalue
+ = extract_signed_integer (valaddr, TYPE_LENGTH (type), byte_order);
if (scm_inferior_print (type, svalue, stream, recurse, options) >= 0)
{
score_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
int *lenptr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[SCORE_INSTLEN] = { 0 };
int ret;
unsigned int raw;
error ("Error: target_read_memory in file:%s, line:%d!",
__FILE__, __LINE__);
}
- raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+ raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ if (byte_order == BFD_ENDIAN_BIG)
{
if (!(raw & 0x80008000))
{
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argnum;
int argreg;
int arglen = 0;
while (arglen > 0)
{
int partial_len = arglen < SCORE_REGSIZE ? arglen : SCORE_REGSIZE;
- ULONGEST regval = extract_unsigned_integer (val, partial_len);
+ ULONGEST regval = extract_unsigned_integer (val, partial_len,
+ byte_order);
/* The last part of a arg should shift left when
gdbarch_byte_order is BFD_ENDIAN_BIG. */
static inst_t *
score_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
static inst_t inst = { 0, 0 };
char buf[SCORE_INSTLEN] = { 0 };
int big;
}
}
- inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN);
+ inst.raw = extract_unsigned_integer (buf, SCORE_INSTLEN, byte_order);
inst.is15 = !(inst.raw & 0x80008000);
inst.v = RM_PBITS (inst.raw);
- big = (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG);
+ big = (byte_order == BFD_ENDIAN_BIG);
if (inst.is15)
{
if (big ^ ((addr & 0x2) == 2))
#define IS_ADD_IMM_FP(x) (((x) & 0xff00) == 0x7e00)
static CORE_ADDR
-sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
+sh_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR pc, CORE_ADDR current_pc,
struct sh_frame_cache *cache, ULONGEST fpscr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST inst;
CORE_ADDR opc;
int offset;
cache->uses_fp = 0;
for (opc = pc + (2 * 28); pc < opc; pc += 2)
{
- inst = read_memory_unsigned_integer (pc, 2);
+ inst = read_memory_unsigned_integer (pc, 2, byte_order);
/* See where the registers will be saved to */
if (IS_PUSH (inst))
{
sav_reg = reg;
offset = (inst & 0xff) << 1;
sav_offset =
- read_memory_integer ((pc + 4) + offset, 2);
+ read_memory_integer ((pc + 4) + offset, 2, byte_order);
}
}
}
sav_reg = reg;
offset = (inst & 0xff) << 2;
sav_offset =
- read_memory_integer (((pc & 0xfffffffc) + 4) + offset, 4);
+ read_memory_integer (((pc & 0xfffffffc) + 4) + offset,
+ 4, byte_order);
}
}
}
sav_offset = GET_SOURCE_REG (inst) << 16;
/* MOVI20 is a 32 bit instruction! */
pc += 2;
- sav_offset |= read_memory_unsigned_integer (pc, 2);
+ sav_offset
+ |= read_memory_unsigned_integer (pc, 2, byte_order);
/* Now sav_offset contains an unsigned 20 bit value.
It must still get sign extended. */
if (sav_offset & 0x00080000)
pc += 2;
for (opc = pc + 12; pc < opc; pc += 2)
{
- inst = read_memory_integer (pc, 2);
+ inst = read_memory_integer (pc, 2, byte_order);
if (IS_MOV_ARG_TO_IND_R14 (inst))
{
reg = GET_SOURCE_REG (inst);
jsr, which will be very confusing. Most likely the next
instruction is going to be IS_MOV_SP_FP in the delay slot. If
so, note that before returning the current pc. */
- inst = read_memory_integer (pc + 2, 2);
+ inst = read_memory_integer (pc + 2, 2, byte_order);
if (IS_MOV_SP_FP (inst))
cache->uses_fp = 1;
break;
return max (pc, start_pc);
cache.sp_offset = -4;
- pc = sh_analyze_prologue (start_pc, (CORE_ADDR) -1, &cache, 0);
+ pc = sh_analyze_prologue (gdbarch, start_pc, (CORE_ADDR) -1, &cache, 0);
if (!cache.uses_fp)
return start_pc;
CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_offset = 0;
int argreg = ARG0_REGNUM;
int flt_argreg = 0;
{
/* Argument goes in a float argument register. */
reg_size = register_size (gdbarch, flt_argreg);
- regval = extract_unsigned_integer (val, reg_size);
+ regval = extract_unsigned_integer (val, reg_size, byte_order);
/* In little endian mode, float types taking two registers
(doubles on sh4, long doubles on sh2e, sh3e and sh4) must
be stored swapped in the argument registers. The below
regval);
val += reg_size;
len -= reg_size;
- regval = extract_unsigned_integer (val, reg_size);
+ regval = extract_unsigned_integer (val, reg_size, byte_order);
}
regcache_cooked_write_unsigned (regcache, flt_argreg++, regval);
}
{
/* there's room in a register */
reg_size = register_size (gdbarch, argreg);
- regval = extract_unsigned_integer (val, reg_size);
+ regval = extract_unsigned_integer (val, reg_size, byte_order);
regcache_cooked_write_unsigned (regcache, argreg++, regval);
}
/* Store the value one register at a time or in one step on stack. */
if (sh_is_renesas_calling_convention (func_type))
/* If the function uses the Renesas ABI, subtract another 4 bytes from
the stack and store the struct return address there. */
- write_memory_unsigned_integer (sp -= 4, 4, struct_addr);
+ write_memory_unsigned_integer (sp -= 4, 4, byte_order, struct_addr);
else
/* Using the gcc ABI, the "struct return pointer" pseudo-argument has
its own dedicated register. */
CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_offset = 0;
int argreg = ARG0_REGNUM;
int argnum;
{
/* there's room in a register */
reg_size = register_size (gdbarch, argreg);
- regval = extract_unsigned_integer (val, reg_size);
+ regval = extract_unsigned_integer (val, reg_size, byte_order);
regcache_cooked_write_unsigned (regcache, argreg++, regval);
}
/* Store the value reg_size bytes at a time. This means that things
if (sh_is_renesas_calling_convention (func_type))
/* If the function uses the Renesas ABI, subtract another 4 bytes from
the stack and store the struct return address there. */
- write_memory_unsigned_integer (sp -= 4, 4, struct_addr);
+ write_memory_unsigned_integer (sp -= 4, 4, byte_order, struct_addr);
else
/* Using the gcc ABI, the "struct return pointer" pseudo-argument has
its own dedicated register. */
sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
int return_register = R0_REGNUM;
int offset;
ULONGEST c;
regcache_cooked_read_unsigned (regcache, R0_REGNUM, &c);
- store_unsigned_integer (valbuf, len, c);
+ store_unsigned_integer (valbuf, len, byte_order, c);
}
else if (len == 8)
{
sh_store_return_value_nofpu (struct type *type, struct regcache *regcache,
const void *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST val;
int len = TYPE_LENGTH (type);
if (len <= 4)
{
- val = extract_unsigned_integer (valbuf, len);
+ val = extract_unsigned_integer (valbuf, len, byte_order);
regcache_cooked_write_unsigned (regcache, R0_REGNUM, val);
}
else
static struct sh_frame_cache *
sh_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct sh_frame_cache *cache;
CORE_ADDR current_pc;
int i;
{
ULONGEST fpscr;
fpscr = get_frame_register_unsigned (this_frame, FPSCR_REGNUM);
- sh_analyze_prologue (cache->pc, current_pc, cache, fpscr);
+ sh_analyze_prologue (gdbarch, cache->pc, current_pc, cache, fpscr);
}
if (!cache->uses_fp)
frame by looking at the stack pointer. For truly "frameless"
functions this might work too. */
cache->base = get_frame_register_unsigned
- (this_frame,
- gdbarch_sp_regnum (get_frame_arch (this_frame)));
+ (this_frame, gdbarch_sp_regnum (gdbarch));
}
/* Now that we have the base address for the stack frame we can
static int
sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = 0, func_end = 0;
if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
/* First search forward until hitting an rts. */
while (addr < func_end
- && !IS_RTS (read_memory_unsigned_integer (addr, 2)))
+ && !IS_RTS (read_memory_unsigned_integer (addr, 2, byte_order)))
addr += 2;
if (addr >= func_end)
return 0;
/* At this point we should find a mov.l @r15+,r14 instruction,
either before or after the rts. If not, then the function has
probably no "normal" epilogue and we bail out here. */
- inst = read_memory_unsigned_integer (addr - 2, 2);
- if (IS_RESTORE_FP (read_memory_unsigned_integer (addr - 2, 2)))
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
+ if (IS_RESTORE_FP (read_memory_unsigned_integer (addr - 2, 2,
+ byte_order)))
addr -= 2;
- else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2)))
+ else if (!IS_RESTORE_FP (read_memory_unsigned_integer (addr + 2, 2,
+ byte_order)))
return 0;
- inst = read_memory_unsigned_integer (addr - 2, 2);
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
/* Step over possible lds.l @r15+,macl. */
if (IS_MACL_LDS (inst))
{
addr -= 2;
- inst = read_memory_unsigned_integer (addr - 2, 2);
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
}
/* Step over possible lds.l @r15+,pr. */
if (IS_LDS (inst))
{
addr -= 2;
- inst = read_memory_unsigned_integer (addr - 2, 2);
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
}
/* Step over possible mov r14,r15. */
if (IS_MOV_FP_SP (inst))
{
addr -= 2;
- inst = read_memory_unsigned_integer (addr - 2, 2);
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
}
/* Now check for FP adjustments, using add #imm,r14 or add rX, r14
&& (IS_ADD_REG_TO_FP (inst) || IS_ADD_IMM_FP (inst)))
{
addr -= 2;
- inst = read_memory_unsigned_integer (addr - 2, 2);
+ inst = read_memory_unsigned_integer (addr - 2, 2, byte_order);
}
/* On SH2a check if the previous instruction was perhaps a MOVI20.
if ((gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a
|| gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_sh2a_nofpu)
&& addr > func_addr + 6
- && IS_MOVI20 (read_memory_unsigned_integer (addr - 4, 2)))
+ && IS_MOVI20 (read_memory_unsigned_integer (addr - 4, 2,
+ byte_order)))
addr -= 4;
if (pc >= addr)
}
static CORE_ADDR
-look_for_args_moves (CORE_ADDR start_pc, int media_mode)
+look_for_args_moves (struct gdbarch *gdbarch,
+ CORE_ADDR start_pc, int media_mode)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR here, end;
int w;
int insn_size = (media_mode ? 4 : 2);
{
if (media_mode)
{
- w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+ w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+ insn_size, byte_order);
here += insn_size;
if (IS_MEDIA_IND_ARG_MOV (w))
{
the SP has been saved, unfortunately. */
int next_insn = read_memory_integer (UNMAKE_ISA32_ADDR (here),
- insn_size);
+ insn_size, byte_order);
here += insn_size;
if (IS_MEDIA_MOV_TO_R14 (next_insn))
start_pc = here;
}
else
{
- w = read_memory_integer (here, insn_size);
+ w = read_memory_integer (here, insn_size, byte_order);
w = w & 0xffff;
here += insn_size;
if (IS_COMPACT_IND_ARG_MOV (w))
is where the debug info says it is. This can happen after
the SP has been saved, unfortunately. */
- int next_insn = 0xffff & read_memory_integer (here, insn_size);
+ int next_insn = 0xffff & read_memory_integer (here, insn_size,
+ byte_order);
here += insn_size;
if (IS_COMPACT_MOV_TO_R14 (next_insn))
start_pc = here;
/* This must be followed by a JSR @r0 instruction and by
a NOP instruction. After these, the prologue is over! */
- int next_insn = 0xffff & read_memory_integer (here, insn_size);
+ int next_insn = 0xffff & read_memory_integer (here, insn_size,
+ byte_order);
here += insn_size;
if (IS_JSR_R0 (next_insn))
{
- next_insn = 0xffff & read_memory_integer (here, insn_size);
+ next_insn = 0xffff & read_memory_integer (here, insn_size,
+ byte_order);
here += insn_size;
if (IS_NOP (next_insn))
}
static CORE_ADDR
-sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
+sh64_skip_prologue_hard_way (struct gdbarch *gdbarch, CORE_ADDR start_pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR here, end;
int updated_fp = 0;
int insn_size = 4;
if (media_mode)
{
- int w = read_memory_integer (UNMAKE_ISA32_ADDR (here), insn_size);
+ int w = read_memory_integer (UNMAKE_ISA32_ADDR (here),
+ insn_size, byte_order);
here += insn_size;
if (IS_STQ_R18_R14 (w) || IS_STQ_R18_R15 (w) || IS_STQ_R14_R15 (w)
|| IS_STL_R14_R15 (w) || IS_STL_R18_R15 (w)
/* Don't bail out yet, we may have arguments stored in
registers here, according to the debug info, so that
gdb can print the frames correctly. */
- start_pc = look_for_args_moves (here - insn_size, media_mode);
+ start_pc = look_for_args_moves (gdbarch,
+ here - insn_size, media_mode);
break;
}
}
else
{
- int w = 0xffff & read_memory_integer (here, insn_size);
+ int w = 0xffff & read_memory_integer (here, insn_size, byte_order);
here += insn_size;
if (IS_STS_R0 (w) || IS_STS_PR (w)
/* Don't bail out yet, we may have arguments stored in
registers here, according to the debug info, so that
gdb can print the frames correctly. */
- start_pc = look_for_args_moves (here - insn_size, media_mode);
+ start_pc = look_for_args_moves (gdbarch,
+ here - insn_size, media_mode);
break;
}
}
if (post_prologue_pc != 0)
return max (pc, post_prologue_pc);
else
- return sh64_skip_prologue_hard_way (pc);
+ return sh64_skip_prologue_hard_way (gdbarch, pc);
}
/* Should call_function allocate stack space for a struct return? */
int gdb_register_number;
int register_number;
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
cache->sp_offset = 0;
{
insn = read_memory_integer (cache->media_mode ? UNMAKE_ISA32_ADDR (pc)
: pc,
- insn_size);
+ insn_size, byte_order);
if (!cache->media_mode)
{
if (IS_STS_PR (insn))
{
- int next_insn = read_memory_integer (pc + insn_size, insn_size);
+ int next_insn = read_memory_integer (pc + insn_size,
+ insn_size, byte_order);
if (IS_MOV_TO_R15 (next_insn))
{
cache->saved_regs[PR_REGNUM] =
CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int stack_offset, stack_alloc;
int int_argreg;
int float_argreg;
if (int_argreg <= ARGLAST_REGNUM)
{
/* there's room in a register */
- regval = extract_unsigned_integer (val, argreg_size);
+ regval = extract_unsigned_integer (val, argreg_size,
+ byte_order);
regcache_cooked_write_unsigned (regcache, int_argreg, regval);
}
/* Store the value 8 bytes at a time. This means that
void *valbuf)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, gdb_byte *buffer)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum;
int portion;
int offset = 0;
/* Get FPSCR into a local buffer */
regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
/* Get value as an int. */
- fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+ fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
/* Get SR into a local buffer */
regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
/* Get value as an int. */
- sr_value = extract_unsigned_integer (temp_buffer, 4);
+ sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
/* Build the new value. */
fpscr_c_part1_value = fpscr_value & 0x3fffd;
fpscr_c_part2_value = (sr_value & 0x7000) << 6;
fpscr_c_value = fpscr_c_part1_value | fpscr_c_part2_value;
/* Store that in out buffer!!! */
- store_unsigned_integer (buffer, 4, fpscr_c_value);
+ store_unsigned_integer (buffer, 4, byte_order, fpscr_c_value);
/* FIXME There is surely an endianness gotcha here. */
}
sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
int reg_nr, const gdb_byte *buffer)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int base_regnum, portion;
int offset;
char temp_buffer[MAX_REGISTER_SIZE];
*/
/* *INDENT-ON* */
/* Get value as an int. */
- fpscr_c_value = extract_unsigned_integer (buffer, 4);
+ fpscr_c_value = extract_unsigned_integer (buffer, 4, byte_order);
/* Build the new values. */
fpscr_mask = 0x0003fffd;
sr_value = (fpscr_value & sr_mask) >> 6;
regcache_raw_read (regcache, fpscr_base_regnum, temp_buffer);
- old_fpscr_value = extract_unsigned_integer (temp_buffer, 4);
+ old_fpscr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
old_fpscr_value &= 0xfffc0002;
fpscr_value |= old_fpscr_value;
- store_unsigned_integer (temp_buffer, 4, fpscr_value);
+ store_unsigned_integer (temp_buffer, 4, byte_order, fpscr_value);
regcache_raw_write (regcache, fpscr_base_regnum, temp_buffer);
regcache_raw_read (regcache, sr_base_regnum, temp_buffer);
- old_sr_value = extract_unsigned_integer (temp_buffer, 4);
+ old_sr_value = extract_unsigned_integer (temp_buffer, 4, byte_order);
old_sr_value &= 0xffff8fff;
sr_value |= old_sr_value;
- store_unsigned_integer (temp_buffer, 4, sr_value);
+ store_unsigned_integer (temp_buffer, 4, byte_order, sr_value);
regcache_raw_write (regcache, sr_base_regnum, temp_buffer);
}
{
struct sh64_frame_cache *cache = sh64_frame_cache (this_frame, this_cache);
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_assert (regnum >= 0);
&& (regnum == MEDIA_FP_REGNUM || regnum == PR_REGNUM))
{
CORE_ADDR val;
- val = read_memory_unsigned_integer (cache->saved_regs[regnum], 4);
+ val = read_memory_unsigned_integer (cache->saved_regs[regnum],
+ 4, byte_order);
return frame_unwind_got_constant (this_frame, regnum, val);
}
darwin_load_image_infos (void)
{
gdb_byte buf[24];
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
int len;
return;
/* Extract the fields. */
- dyld_all_image.version = extract_unsigned_integer (buf, 4);
+ dyld_all_image.version = extract_unsigned_integer (buf, 4, byte_order);
if (dyld_all_image.version != DYLD_VERSION)
return;
- dyld_all_image.count = extract_unsigned_integer (buf + 4, 4);
+ dyld_all_image.count = extract_unsigned_integer (buf + 4, 4, byte_order);
dyld_all_image.info = extract_typed_address (buf + 8, ptr_type);
dyld_all_image.notifier = extract_typed_address
(buf + 8 + ptr_type->length, ptr_type);
static struct int_elf32_fdpic_loadmap *
fetch_loadmap (CORE_ADDR ldmaddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct ext_elf32_fdpic_loadmap ext_ldmbuf_partial;
struct ext_elf32_fdpic_loadmap *ext_ldmbuf;
struct int_elf32_fdpic_loadmap *int_ldmbuf;
/* Extract the version. */
version = extract_unsigned_integer (ext_ldmbuf_partial.version,
- sizeof ext_ldmbuf_partial.version);
+ sizeof ext_ldmbuf_partial.version,
+ byte_order);
if (version != 0)
{
/* We only handle version 0. */
/* Extract the number of segments. */
nsegs = extract_unsigned_integer (ext_ldmbuf_partial.nsegs,
- sizeof ext_ldmbuf_partial.nsegs);
+ sizeof ext_ldmbuf_partial.nsegs,
+ byte_order);
if (nsegs <= 0)
return NULL;
{
int_ldmbuf->segs[seg].addr
= extract_unsigned_integer (ext_ldmbuf->segs[seg].addr,
- sizeof (ext_ldmbuf->segs[seg].addr));
+ sizeof (ext_ldmbuf->segs[seg].addr),
+ byte_order);
int_ldmbuf->segs[seg].p_vaddr
= extract_unsigned_integer (ext_ldmbuf->segs[seg].p_vaddr,
- sizeof (ext_ldmbuf->segs[seg].p_vaddr));
+ sizeof (ext_ldmbuf->segs[seg].p_vaddr),
+ byte_order);
int_ldmbuf->segs[seg].p_memsz
= extract_unsigned_integer (ext_ldmbuf->segs[seg].p_memsz,
- sizeof (ext_ldmbuf->segs[seg].p_memsz));
+ sizeof (ext_ldmbuf->segs[seg].p_memsz),
+ byte_order);
}
xfree (ext_ldmbuf);
static CORE_ADDR
lm_base (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct minimal_symbol *got_sym;
CORE_ADDR addr;
gdb_byte buf[FRV_PTR_SIZE];
if (target_read_memory (addr, buf, sizeof buf) != 0)
return 0;
- lm_base_cache = extract_unsigned_integer (buf, sizeof buf);
+ lm_base_cache = extract_unsigned_integer (buf, sizeof buf, byte_order);
if (solib_frv_debug)
fprintf_unfiltered (gdb_stdlog,
static struct so_list *
frv_current_sos (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR lm_addr, mgot;
struct so_list *sos_head = NULL;
struct so_list **sos_next_ptr = &sos_head;
got_addr
= extract_unsigned_integer (lm_buf.l_addr.got_value,
- sizeof (lm_buf.l_addr.got_value));
+ sizeof (lm_buf.l_addr.got_value),
+ byte_order);
/* If the got_addr is the same as mgotr, then we're looking at the
entry for the main executable. By convention, we don't include
this in the list of shared objects. */
/* Fetch the load map address. */
addr = extract_unsigned_integer (lm_buf.l_addr.map,
- sizeof lm_buf.l_addr.map);
+ sizeof lm_buf.l_addr.map,
+ byte_order);
loadmap = fetch_loadmap (addr);
if (loadmap == NULL)
{
sop->lm_info->lm_addr = lm_addr;
/* Fetch the name. */
addr = extract_unsigned_integer (lm_buf.l_name,
- sizeof (lm_buf.l_name));
+ sizeof (lm_buf.l_name),
+ byte_order);
target_read_string (addr, &name_buf, SO_NAME_MAX_PATH_SIZE - 1,
&errcode);
main_lm_addr = lm_addr;
}
- lm_addr = extract_unsigned_integer (lm_buf.l_next, sizeof (lm_buf.l_next));
+ lm_addr = extract_unsigned_integer (lm_buf.l_next,
+ sizeof (lm_buf.l_next), byte_order);
}
enable_break2 ();
static int
enable_break2 (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int success = 0;
char **bkpt_namep;
asection *interp_sect;
warning (_("Unable to fetch contents of _dl_debug_addr (at address %s) from dynamic linker"),
hex_string_custom (addr, 8));
}
- addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+ addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
/* Fetch the r_brk field. It's 8 bytes from the start of
_dl_debug_addr. */
bfd_close (tmp_bfd);
return 0;
}
- addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+ addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
/* Now fetch the function entry point. */
if (target_read_memory (addr, addr_buf, sizeof addr_buf) != 0)
bfd_close (tmp_bfd);
return 0;
}
- addr = extract_unsigned_integer (addr_buf, sizeof addr_buf);
+ addr = extract_unsigned_integer (addr_buf, sizeof addr_buf, byte_order);
/* We're done with the temporary bfd. */
bfd_close (tmp_bfd);
(CORE_ADDR entry_point, CORE_ADDR got_value, char *name, bfd *abfd,
struct lm_info *lm)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
arelent *rel;
unsigned int i;
CORE_ADDR addr = 0;
/* Fetch address of candidate descriptor. */
if (target_read_memory (addr, buf, sizeof buf) != 0)
continue;
- addr = extract_unsigned_integer (buf, sizeof buf);
+ addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
/* Check for matching entry point. */
if (target_read_memory (addr, buf, sizeof buf) != 0)
continue;
- if (extract_unsigned_integer (buf, sizeof buf) != entry_point)
+ if (extract_unsigned_integer (buf, sizeof buf, byte_order)
+ != entry_point)
continue;
/* Check for matching got value. */
if (target_read_memory (addr + 4, buf, sizeof buf) != 0)
continue;
- if (extract_unsigned_integer (buf, sizeof buf) != got_value)
+ if (extract_unsigned_integer (buf, sizeof buf, byte_order)
+ != got_value)
continue;
/* Match was successful! Exit loop. */
appropriate type. Calling extract_signed_integer seems simpler. */
static CORE_ADDR
-extract_mips_address (void *addr, int len)
+extract_mips_address (void *addr, int len, enum bfd_endian byte_order)
{
- return extract_signed_integer (addr, len);
+ return extract_signed_integer (addr, len, byte_order);
}
/* Fetch and return the link map data associated with ADDR. Note that
static struct lm_info
fetch_lm_info (CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct lm_info li;
union irix_obj_info buf;
being at the end of a page or the like.) */
read_memory (addr, (char *) &buf, sizeof (buf.ol32));
- if (extract_unsigned_integer (buf.magic.b, sizeof (buf.magic)) != 0xffffffff)
+ if (extract_unsigned_integer (buf.magic.b, sizeof (buf.magic), byte_order)
+ != 0xffffffff)
{
/* Use buf.ol32... */
char obj_buf[432];
CORE_ADDR obj_addr = extract_mips_address (&buf.ol32.data,
- sizeof (buf.ol32.data));
- li.next = extract_mips_address (&buf.ol32.next, sizeof (buf.ol32.next));
+ sizeof (buf.ol32.data),
+ byte_order);
+ li.next = extract_mips_address (&buf.ol32.next,
+ sizeof (buf.ol32.next), byte_order);
read_memory (obj_addr, obj_buf, sizeof (obj_buf));
- li.pathname_addr = extract_mips_address (&obj_buf[236], 4);
+ li.pathname_addr = extract_mips_address (&obj_buf[236], 4, byte_order);
li.pathname_len = 0; /* unknown */
- li.reloc_offset = extract_mips_address (&obj_buf[196], 4)
- - extract_mips_address (&obj_buf[248], 4);
+ li.reloc_offset = extract_mips_address (&obj_buf[196], 4, byte_order)
+ - extract_mips_address (&obj_buf[248], 4, byte_order);
}
else if (extract_unsigned_integer (buf.oi32.oi_size.b,
- sizeof (buf.oi32.oi_size))
+ sizeof (buf.oi32.oi_size), byte_order)
== sizeof (buf.oi32))
{
/* Use buf.oi32... */
/* Fill in fields using buffer contents. */
li.next = extract_mips_address (&buf.oi32.oi_next,
- sizeof (buf.oi32.oi_next));
+ sizeof (buf.oi32.oi_next), byte_order);
li.reloc_offset = extract_mips_address (&buf.oi32.oi_ehdr,
- sizeof (buf.oi32.oi_ehdr))
+ sizeof (buf.oi32.oi_ehdr),
+ byte_order)
- extract_mips_address (&buf.oi32.oi_orig_ehdr,
- sizeof (buf.oi32.oi_orig_ehdr));
+ sizeof (buf.oi32.oi_orig_ehdr), byte_order);
li.pathname_addr = extract_mips_address (&buf.oi32.oi_pathname,
- sizeof (buf.oi32.oi_pathname));
+ sizeof (buf.oi32.oi_pathname),
+ byte_order);
li.pathname_len = extract_unsigned_integer (buf.oi32.oi_pathname_len.b,
sizeof (buf.oi32.
- oi_pathname_len));
+ oi_pathname_len),
+ byte_order);
}
else if (extract_unsigned_integer (buf.oi64.oi_size.b,
- sizeof (buf.oi64.oi_size))
+ sizeof (buf.oi64.oi_size), byte_order)
== sizeof (buf.oi64))
{
/* Use buf.oi64... */
/* Fill in fields using buffer contents. */
li.next = extract_mips_address (&buf.oi64.oi_next,
- sizeof (buf.oi64.oi_next));
+ sizeof (buf.oi64.oi_next), byte_order);
li.reloc_offset = extract_mips_address (&buf.oi64.oi_ehdr,
- sizeof (buf.oi64.oi_ehdr))
+ sizeof (buf.oi64.oi_ehdr),
+ byte_order)
- extract_mips_address (&buf.oi64.oi_orig_ehdr,
- sizeof (buf.oi64.oi_orig_ehdr));
+ sizeof (buf.oi64.oi_orig_ehdr), byte_order);
li.pathname_addr = extract_mips_address (&buf.oi64.oi_pathname,
- sizeof (buf.oi64.oi_pathname));
+ sizeof (buf.oi64.oi_pathname),
+ byte_order);
li.pathname_len = extract_unsigned_integer (buf.oi64.oi_pathname_len.b,
sizeof (buf.oi64.
- oi_pathname_len));
+ oi_pathname_len),
+ byte_order);
}
else
{
static struct so_list *
irix_current_sos (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ int addr_size = gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT;
CORE_ADDR lma;
char addr_buf[8];
struct so_list *head = 0;
return 0;
}
- read_memory (debug_base,
- addr_buf,
- gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT);
- lma = extract_mips_address (addr_buf,
- gdbarch_addr_bit (target_gdbarch)
- / TARGET_CHAR_BIT);
+ read_memory (debug_base, addr_buf, addr_size);
+ lma = extract_mips_address (addr_buf, addr_size, byte_order);
while (lma)
{
static int
irix_open_symbol_file_object (void *from_ttyp)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
+ int addr_size = gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT;
CORE_ADDR lma;
char addr_buf[8];
struct lm_info lm;
return 0; /* failed somehow... */
/* First link map member should be the executable. */
- read_memory (debug_base,
- addr_buf,
- gdbarch_addr_bit (target_gdbarch) / TARGET_CHAR_BIT);
- lma = extract_mips_address (addr_buf,
- gdbarch_addr_bit (target_gdbarch)
- / TARGET_CHAR_BIT);
+ read_memory (debug_base, addr_buf, addr_size);
+ lma = extract_mips_address (addr_buf, addr_size, byte_order);
if (lma == 0)
return 0; /* failed somehow... */
static void
som_solib_create_inferior_hook (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct minimal_symbol *msymbol;
unsigned int dld_flags, status, have_endo;
asection *shlib_info;
goto keep_going;
anaddr = SYMBOL_VALUE_ADDRESS (msymbol);
- store_unsigned_integer (buf, 4, PIDGET (inferior_ptid));
+ store_unsigned_integer (buf, 4, byte_order, PIDGET (inferior_ptid));
status = target_write_memory (anaddr, buf, 4);
if (status != 0)
{
anaddr = SYMBOL_VALUE (msymbol);
dld_cache.hook_stub.address = anaddr;
}
- store_unsigned_integer (buf, 4, anaddr);
+ store_unsigned_integer (buf, 4, byte_order, anaddr);
msymbol = lookup_minimal_symbol ("__dld_hook", NULL, symfile_objfile);
if (msymbol == NULL)
status = target_read_memory (anaddr, buf, 4);
if (status != 0)
error (_("Unable to read __dld_flags."));
- dld_flags = extract_unsigned_integer (buf, 4);
+ dld_flags = extract_unsigned_integer (buf, 4, byte_order);
/* If the libraries were not mapped private on HP-UX 11 and later, warn
the user. On HP-UX 10 and earlier, there is no easy way to specify
dld_flags |= DLD_FLAGS_MAPPRIVATE;
if (have_endo)
dld_flags |= DLD_FLAGS_HOOKVALID;
- store_unsigned_integer (buf, 4, dld_flags);
+ store_unsigned_integer (buf, 4, byte_order, dld_flags);
status = target_write_memory (anaddr, buf, 4);
if (status != 0)
error (_("Unable to write __dld_flags."));
static CORE_ADDR
link_map_start (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
struct minimal_symbol *sym;
CORE_ADDR addr;
char buf[4];
error (_("Unable to find __dld_flags symbol in object file."));
addr = SYMBOL_VALUE_ADDRESS (sym);
read_memory (addr, buf, 4);
- dld_flags = extract_unsigned_integer (buf, 4);
+ dld_flags = extract_unsigned_integer (buf, 4, byte_order);
if ((dld_flags & DLD_FLAGS_LISTVALID) == 0)
error (_("__dld_list is not valid according to __dld_flags."));
addr = SYMBOL_VALUE_ADDRESS (sym);
read_memory (addr, buf, 4);
- addr = extract_unsigned_integer (buf, 4);
+ addr = extract_unsigned_integer (buf, 4, byte_order);
if (addr == 0)
return 0;
read_memory (addr, buf, 4);
- return extract_unsigned_integer (buf, 4);
+ return extract_unsigned_integer (buf, 4, byte_order);
}
/* Does this so's name match the main binary? */
static struct so_list *
som_current_sos (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR lm;
struct so_list *head = 0;
struct so_list **link_ptr = &head;
read_memory (lm, (gdb_byte *)&dbuf, sizeof (struct dld_list));
addr = extract_unsigned_integer ((gdb_byte *)&dbuf.name,
- sizeof (dbuf.name));
+ sizeof (dbuf.name), byte_order);
target_read_string (addr, &namebuf, SO_NAME_MAX_PATH_SIZE - 1, &errcode);
if (errcode != 0)
warning (_("Can't read pathname for load map: %s."),
lmi->lm_addr = lm;
#define EXTRACT(_fld) \
- extract_unsigned_integer ((gdb_byte *)&dbuf._fld, sizeof (dbuf._fld));
+ extract_unsigned_integer ((gdb_byte *)&dbuf._fld, \
+ sizeof (dbuf._fld), byte_order);
lmi->text_addr = EXTRACT (text_addr);
tmp = EXTRACT (info);
lmi->got_value = EXTRACT (got_value);
tmp = EXTRACT (tsd_start_addr_ptr);
read_memory (tmp, tsdbuf, 4);
- lmi->tsd_start_addr = extract_unsigned_integer (tsdbuf, 4);
+ lmi->tsd_start_addr
+ = extract_unsigned_integer (tsdbuf, 4, byte_order);
#ifdef SOLIB_SOM_DBG
printf ("\n+ library \"%s\" is described at %s\n", new->so_name,
static int
som_open_symbol_file_object (void *from_ttyp)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR lm, l_name;
char *filename;
int errcode;
/* Convert the address to host format. Assume that the address is
unsigned. */
- l_name = extract_unsigned_integer (buf, 4);
+ l_name = extract_unsigned_integer (buf, 4, byte_order);
if (l_name == 0)
return 0; /* No filename. */
Assume that the address is unsigned. */
#define SOLIB_EXTRACT_ADDRESS(MEMBER) \
- extract_unsigned_integer (&(MEMBER), sizeof (MEMBER))
+ extract_unsigned_integer (&(MEMBER), sizeof (MEMBER), \
+ gdbarch_byte_order (target_gdbarch))
/* local data declarations */
static CORE_ADDR
LM_ADDR (struct so_list *so)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int lm_addr_offset = offsetof (struct link_map, lm_addr);
int lm_addr_size = fieldsize (struct link_map, lm_addr);
return (CORE_ADDR) extract_signed_integer (so->lm_info->lm + lm_addr_offset,
- lm_addr_size);
+ lm_addr_size, byte_order);
}
static CORE_ADDR
LM_NEXT (struct so_list *so)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int lm_next_offset = offsetof (struct link_map, lm_next);
int lm_next_size = fieldsize (struct link_map, lm_next);
/* Assume that the address is unsigned. */
return extract_unsigned_integer (so->lm_info->lm + lm_next_offset,
- lm_next_size);
+ lm_next_size, byte_order);
}
static CORE_ADDR
LM_NAME (struct so_list *so)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int lm_name_offset = offsetof (struct link_map, lm_name);
int lm_name_size = fieldsize (struct link_map, lm_name);
/* Assume that the address is unsigned. */
return extract_unsigned_integer (so->lm_info->lm + lm_name_offset,
- lm_name_size);
+ lm_name_size, byte_order);
}
static CORE_ADDR debug_base; /* Base of dynamic linker structures */
static gdb_byte *
read_program_header (int type, int *p_sect_size, int *p_arch_size)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
CORE_ADDR at_phdr, at_phent, at_phnum;
int arch_size, sect_size;
CORE_ADDR sect_addr;
(gdb_byte *)&phdr, sizeof (phdr)))
return 0;
- if (extract_unsigned_integer ((gdb_byte *)phdr.p_type, 4) == type)
+ if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
+ 4, byte_order) == type)
break;
}
return 0;
/* Retrieve address and size. */
- sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr, 4);
- sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz, 4);
+ sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
+ 4, byte_order);
+ sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
+ 4, byte_order);
}
else
{
(gdb_byte *)&phdr, sizeof (phdr)))
return 0;
- if (extract_unsigned_integer ((gdb_byte *)phdr.p_type, 4) == type)
+ if (extract_unsigned_integer ((gdb_byte *)phdr.p_type,
+ 4, byte_order) == type)
break;
}
return 0;
/* Retrieve address and size. */
- sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr, 8);
- sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz, 8);
+ sect_addr = extract_unsigned_integer ((gdb_byte *)phdr.p_vaddr,
+ 8, byte_order);
+ sect_size = extract_unsigned_integer ((gdb_byte *)phdr.p_memsz,
+ 8, byte_order);
}
/* Read in requested program header. */
static int
scan_dyntag_auxv (int dyntag, CORE_ADDR *ptr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int sect_size, arch_size, step;
long dyn_tag;
CORE_ADDR dyn_ptr;
if (arch_size == 32)
{
Elf32_External_Dyn *dynp = (Elf32_External_Dyn *) buf;
- dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 4);
- dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 4);
+ dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
+ 4, byte_order);
+ dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
+ 4, byte_order);
}
else
{
Elf64_External_Dyn *dynp = (Elf64_External_Dyn *) buf;
- dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag, 8);
- dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr, 8);
+ dyn_tag = extract_unsigned_integer ((gdb_byte *) dynp->d_tag,
+ 8, byte_order);
+ dyn_ptr = extract_unsigned_integer ((gdb_byte *) dynp->d_un.d_ptr,
+ 8, byte_order);
}
if (dyn_tag == DT_NULL)
break;
{
struct link_map_offsets *lmo = svr4_fetch_link_map_offsets ();
struct type *ptr_type = builtin_type (target_gdbarch)->builtin_data_ptr;
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
ULONGEST version;
/* Check version, and return zero if `struct r_debug' doesn't have
the r_ldsomap member. */
version
= read_memory_unsigned_integer (info->debug_base + lmo->r_version_offset,
- lmo->r_version_size);
+ lmo->r_version_size, byte_order);
if (version < 2 || lmo->r_ldsomap_offset == -1)
return 0;
/* __NR_rt_sigreturn is 101 and __NR_sigreturn is 216 */
if (sc_num == 101 || sc_num == 216)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
ULONGEST sp, pc_offset;
sp = get_frame_register_unsigned (frame, SPARC_SP_REGNUM);
if (sc_num == 101)
pc_offset += 128;
- return read_memory_unsigned_integer (sp + pc_offset, 4);
+ return read_memory_unsigned_integer (sp + pc_offset, 4, byte_order);
}
}
/* Fetch StackGhost Per-Process XOR cookie. */
ULONGEST
-sparc_fetch_wcookie (void)
+sparc_fetch_wcookie (struct gdbarch *gdbarch)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct target_ops *ops = ¤t_target;
gdb_byte buf[8];
int len;
/* We should have either an 32-bit or an 64-bit cookie. */
gdb_assert (len == 4 || len == 8);
- return extract_unsigned_integer (buf, len);
+ return extract_unsigned_integer (buf, len, byte_order);
}
\f
CORE_ADDR *real_pc, CORE_ADDR *bp_addr,
struct regcache *regcache)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
*bp_addr = sp - 4;
*real_pc = funcaddr;
gdb_byte buf[4];
/* This is an UNIMP instruction. */
- store_unsigned_integer (buf, 4, TYPE_LENGTH (value_type) & 0x1fff);
+ store_unsigned_integer (buf, 4, byte_order,
+ TYPE_LENGTH (value_type) & 0x1fff);
write_memory (sp - 8, buf, 4);
return sp - 8;
}
int struct_return, CORE_ADDR struct_addr)
{
struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
/* Number of words in the "parameter array". */
int num_elements = 0;
int element = 0;
{
gdb_byte buf[4];
- store_unsigned_integer (buf, 4, struct_addr);
+ store_unsigned_integer (buf, 4, byte_order, struct_addr);
write_memory (sp, buf, 4);
}
sparc32_frame_prev_register (struct frame_info *this_frame,
void **this_cache, int regnum)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct sparc_frame_cache *cache =
sparc32_frame_cache (this_frame, this_cache);
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
{
struct type *type, struct regcache *regcache,
gdb_byte *readbuf, const gdb_byte *writebuf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
/* The psABI says that "...every stack frame reserves the word at
%fp+64. If a function returns a structure, union, or
quad-precision value, this word should hold the address of the
CORE_ADDR addr;
regcache_cooked_read_unsigned (regcache, SPARC_SP_REGNUM, &sp);
- addr = read_memory_unsigned_integer (sp + 64, 4);
+ addr = read_memory_unsigned_integer (sp + 64, 4, byte_order);
read_memory (addr, readbuf, TYPE_LENGTH (type));
}
void
sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int offset = 0;
gdb_byte buf[8];
int i;
/* Handle StackGhost. */
if (i == SPARC_I7_REGNUM)
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
- ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+ ULONGEST i7;
- store_unsigned_integer (buf + offset, 8, i7 ^ wcookie);
+ i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+ store_unsigned_integer (buf + offset, 8, byte_order,
+ i7 ^ wcookie);
}
regcache_raw_supply (regcache, i, buf);
/* Handle StackGhost. */
if (i == SPARC_I7_REGNUM)
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
- ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+ ULONGEST i7;
- store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+ i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+ store_unsigned_integer (buf + offset, 4, byte_order,
+ i7 ^ wcookie);
}
regcache_raw_supply (regcache, i, buf);
sparc_collect_rwindow (const struct regcache *regcache,
CORE_ADDR sp, int regnum)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int offset = 0;
gdb_byte buf[8];
int i;
/* Handle StackGhost. */
if (i == SPARC_I7_REGNUM)
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
- ULONGEST i7 = extract_unsigned_integer (buf + offset, 8);
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+ ULONGEST i7;
- store_unsigned_integer (buf, 8, i7 ^ wcookie);
+ i7 = extract_unsigned_integer (buf + offset, 8, byte_order);
+ store_unsigned_integer (buf, 8, byte_order, i7 ^ wcookie);
}
target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 8), buf, 8);
/* Handle StackGhost. */
if (i == SPARC_I7_REGNUM)
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
- ULONGEST i7 = extract_unsigned_integer (buf + offset, 4);
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
+ ULONGEST i7;
- store_unsigned_integer (buf + offset, 4, i7 ^ wcookie);
+ i7 = extract_unsigned_integer (buf + offset, 4, byte_order);
+ store_unsigned_integer (buf + offset, 4, byte_order,
+ i7 ^ wcookie);
}
target_write_memory (sp + ((i - SPARC_L0_REGNUM) * 4),
extern unsigned long sparc_fetch_instruction (CORE_ADDR pc);
/* Fetch StackGhost Per-Process XOR cookie. */
-extern ULONGEST sparc_fetch_wcookie (void);
+extern ULONGEST sparc_fetch_wcookie (struct gdbarch *gdbarch);
extern CORE_ADDR sparc_analyze_prologue (struct gdbarch *gdbarch,
CORE_ADDR pc, CORE_ADDR current_pc,
{
if (insn == 0x91d0206d)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
ULONGEST sp = get_frame_register_unsigned (frame, SPARC_SP_REGNUM);
if (sp & 1)
sp += BIAS;
register save area. The saved PC sits at a 136 byte offset
into there. */
- return read_memory_unsigned_integer (sp + 192 + 128 + 136, 8);
+ return read_memory_unsigned_integer (sp + 192 + 128 + 136,
+ 8, byte_order);
}
return 0;
struct regcache *regcache,
int regnum, gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_assert (regnum >= SPARC64_NUM_REGS);
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
state = (state >> 32) & ((1 << 8) - 1);
break;
}
- store_unsigned_integer (buf, 8, state);
+ store_unsigned_integer (buf, 8, byte_order, state);
}
}
struct regcache *regcache,
int regnum, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_assert (regnum >= SPARC64_NUM_REGS);
if (regnum >= SPARC64_D0_REGNUM && regnum <= SPARC64_D30_REGNUM)
ULONGEST state, bits;
regcache_raw_read_unsigned (regcache, SPARC64_STATE_REGNUM, &state);
- bits = extract_unsigned_integer (buf, 8);
+ bits = extract_unsigned_integer (buf, 8, byte_order);
switch (regnum)
{
case SPARC64_CWP_REGNUM:
sparc64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
int regnum)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct sparc_frame_cache *cache =
sparc64_frame_cache (this_frame, this_cache);
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
{
struct regcache *regcache,
int regnum, const void *gregs)
{
- int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
const gdb_byte *regs = gregs;
int i;
ULONGEST tstate, psr;
gdb_byte buf[4];
- tstate = extract_unsigned_integer (regs + offset, 8);
+ tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
psr = ((tstate & TSTATE_CWP) | PSR_S | ((tstate & TSTATE_ICC) >> 12)
| ((tstate & TSTATE_XCC) >> 20) | PSR_V8PLUS);
- store_unsigned_integer (buf, 4, psr);
+ store_unsigned_integer (buf, 4, byte_order, psr);
regcache_raw_supply (regcache, SPARC32_PSR_REGNUM, buf);
}
const struct regcache *regcache,
int regnum, void *gregs)
{
- int sparc32 = (gdbarch_ptr_bit (get_regcache_arch (regcache)) == 32);
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int sparc32 = (gdbarch_ptr_bit (gdbarch) == 32);
gdb_byte *regs = gregs;
int i;
ULONGEST tstate, psr;
gdb_byte buf[8];
- tstate = extract_unsigned_integer (regs + offset, 8);
+ tstate = extract_unsigned_integer (regs + offset, 8, byte_order);
regcache_raw_collect (regcache, SPARC32_PSR_REGNUM, buf);
- psr = extract_unsigned_integer (buf, 4);
+ psr = extract_unsigned_integer (buf, 4, byte_order);
tstate |= (psr & PSR_ICC) << 12;
if ((psr & (PSR_VERS | PSR_IMPL)) == PSR_V8PLUS)
tstate |= (psr & PSR_XCC) << 20;
- store_unsigned_integer (buf, 8, tstate);
+ store_unsigned_integer (buf, 8, byte_order, tstate);
memcpy (regs + offset, buf, 8);
}
sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct trad_frame_saved_reg *saved_regs;
CORE_ADDR addr, sp;
int regnum, delta;
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0)
{
sparc64obsd_supply_uthread (struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR fp, fp_addr = addr + SPARC64OBSD_UTHREAD_FP_OFFSET;
gdb_byte buf[8];
gdb_assert (regnum >= -1);
- fp = read_memory_unsigned_integer (fp_addr, 8);
+ fp = read_memory_unsigned_integer (fp_addr, 8, byte_order);
if (regnum == SPARC_SP_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 8, fp);
+ store_unsigned_integer (buf, 8, byte_order, fp);
regcache_raw_supply (regcache, SPARC_SP_REGNUM, buf);
if (regnum == SPARC_SP_REGNUM)
{
CORE_ADDR i7, i7_addr = addr + SPARC64OBSD_UTHREAD_PC_OFFSET;
- i7 = read_memory_unsigned_integer (i7_addr, 8);
+ i7 = read_memory_unsigned_integer (i7_addr, 8, byte_order);
if (regnum == SPARC64_PC_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 8, i7 + 8);
+ store_unsigned_integer (buf, 8, byte_order, i7 + 8);
regcache_raw_supply (regcache, SPARC64_PC_REGNUM, buf);
}
if (regnum == SPARC64_NPC_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 8, i7 + 12);
+ store_unsigned_integer (buf, 8, byte_order, i7 + 12);
regcache_raw_supply (regcache, SPARC64_NPC_REGNUM, buf);
}
sparc64obsd_collect_uthread(const struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
gdb_byte buf[8];
CORE_ADDR i7, i7_addr = addr + SPARC64OBSD_UTHREAD_PC_OFFSET;
regcache_raw_collect (regcache, SPARC64_PC_REGNUM, buf);
- i7 = extract_unsigned_integer (buf, 8) - 8;
- write_memory_unsigned_integer (i7_addr, 8, i7);
+ i7 = extract_unsigned_integer (buf, 8, byte_order) - 8;
+ write_memory_unsigned_integer (i7_addr, 8, byte_order, i7);
if (regnum == SPARC64_PC_REGNUM)
return;
}
regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 8);
+ sp = extract_unsigned_integer (buf, 8, byte_order);
sparc_collect_rwindow (regcache, sp, regnum);
}
\f
struct trad_frame_saved_reg *
sparc32nbsd_sigcontext_saved_regs (struct frame_info *this_frame)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct trad_frame_saved_reg *saved_regs;
CORE_ADDR addr, sigcontext_addr;
int regnum, delta;
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0)
{
sparc32obsd_supply_uthread (struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR fp, fp_addr = addr + SPARC32OBSD_UTHREAD_FP_OFFSET;
gdb_byte buf[4];
gdb_assert (regnum >= -1);
- fp = read_memory_unsigned_integer (fp_addr, 4);
+ fp = read_memory_unsigned_integer (fp_addr, 4, byte_order);
if (regnum == SPARC_SP_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 4, fp);
+ store_unsigned_integer (buf, 4, byte_order, fp);
regcache_raw_supply (regcache, SPARC_SP_REGNUM, buf);
if (regnum == SPARC_SP_REGNUM)
{
CORE_ADDR i7, i7_addr = addr + SPARC32OBSD_UTHREAD_PC_OFFSET;
- i7 = read_memory_unsigned_integer (i7_addr, 4);
+ i7 = read_memory_unsigned_integer (i7_addr, 4, byte_order);
if (regnum == SPARC32_PC_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 4, i7 + 8);
+ store_unsigned_integer (buf, 4, byte_order, i7 + 8);
regcache_raw_supply (regcache, SPARC32_PC_REGNUM, buf);
}
if (regnum == SPARC32_NPC_REGNUM || regnum == -1)
{
- store_unsigned_integer (buf, 4, i7 + 12);
+ store_unsigned_integer (buf, 4, byte_order, i7 + 12);
regcache_raw_supply (regcache, SPARC32_NPC_REGNUM, buf);
}
sparc32obsd_collect_uthread(const struct regcache *regcache,
int regnum, CORE_ADDR addr)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp;
gdb_byte buf[4];
CORE_ADDR i7, i7_addr = addr + SPARC32OBSD_UTHREAD_PC_OFFSET;
regcache_raw_collect (regcache, SPARC32_PC_REGNUM, buf);
- i7 = extract_unsigned_integer (buf, 4) - 8;
- write_memory_unsigned_integer (i7_addr, 4, i7);
+ i7 = extract_unsigned_integer (buf, 4, byte_order) - 8;
+ write_memory_unsigned_integer (i7_addr, 4, byte_order, i7);
if (regnum == SPARC32_PC_REGNUM)
return;
}
regcache_raw_collect (regcache, SPARC_SP_REGNUM, buf);
- sp = extract_unsigned_integer (buf, 4);
+ sp = extract_unsigned_integer (buf, 4, byte_order);
sparc_collect_rwindow (regcache, sp, regnum);
}
\f
static int
parse_spufs_run (int *fd, ULONGEST *addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
gdb_byte buf[4];
ULONGEST pc = fetch_ppc_register (32); /* nip */
if (fetch_ppc_memory (pc-4, buf, 4) != 0)
return 0;
/* It should be a "sc" instruction. */
- if (extract_unsigned_integer (buf, 4) != INSTR_SC)
+ if (extract_unsigned_integer (buf, 4, byte_order) != INSTR_SC)
return 0;
/* System call number should be NR_spu_run. */
if (fetch_ppc_register (0) != NR_spu_run)
/* The ID register holds the spufs file handle. */
if (regno == -1 || regno == SPU_ID_REGNUM)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
char buf[4];
- store_unsigned_integer (buf, 4, fd);
+ store_unsigned_integer (buf, 4, byte_order, fd);
regcache_raw_supply (regcache, SPU_ID_REGNUM, buf);
}
spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
gdb_byte *buf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte reg[32];
char annex[32];
ULONGEST id;
target_read (¤t_target, TARGET_OBJECT_SPU, annex,
reg, 0, sizeof reg);
- store_unsigned_integer (buf, 4, strtoulst (reg, NULL, 16));
+ store_unsigned_integer (buf, 4, byte_order, strtoulst (reg, NULL, 16));
}
static void
spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
const gdb_byte *buf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte reg[32];
char annex[32];
ULONGEST id;
regcache_raw_read_unsigned (regcache, SPU_ID_REGNUM, &id);
xsnprintf (annex, sizeof annex, "%d/%s", (int) id, regname);
xsnprintf (reg, sizeof reg, "0x%s",
- phex_nz (extract_unsigned_integer (buf, 4), 4));
+ phex_nz (extract_unsigned_integer (buf, 4, byte_order), 4));
target_write (¤t_target, TARGET_OBJECT_SPU, annex,
reg, 0, strlen (reg));
}
spu_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
- ULONGEST addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ ULONGEST addr
+ = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
ULONGEST lslr = SPU_LS_SIZE - 1; /* Hard-wired LS size. */
if (target_has_registers && target_has_stack && target_has_memory)
};
static CORE_ADDR
-spu_analyze_prologue (CORE_ADDR start_pc, CORE_ADDR end_pc,
+spu_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start_pc, CORE_ADDR end_pc,
struct spu_prologue_data *data)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int found_sp = 0;
int found_fp = 0;
int found_lr = 0;
if (target_read_memory (pc, buf, 4))
break;
- insn = extract_unsigned_integer (buf, 4);
+ insn = extract_unsigned_integer (buf, 4, byte_order);
/* AI is the typical instruction to set up a stack frame.
It is also used to initialize the frame pointer. */
spu_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
struct spu_prologue_data data;
- return spu_analyze_prologue (pc, (CORE_ADDR)-1, &data);
+ return spu_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
}
/* Return the frame pointer in use at address PC. */
int *reg, LONGEST *offset)
{
struct spu_prologue_data data;
- spu_analyze_prologue (pc, (CORE_ADDR)-1, &data);
+ spu_analyze_prologue (gdbarch, pc, (CORE_ADDR)-1, &data);
if (data.size != -1 && data.cfa_reg != -1)
{
static int
spu_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR scan_pc, func_start, func_end, epilogue_start, epilogue_end;
bfd_byte buf[4];
unsigned int insn;
{
if (target_read_memory (scan_pc, buf, 4))
return 0;
- insn = extract_unsigned_integer (buf, 4);
+ insn = extract_unsigned_integer (buf, 4, byte_order);
if (is_branch (insn, &immed, &ra))
{
{
if (target_read_memory (scan_pc, buf, 4))
return 0;
- insn = extract_unsigned_integer (buf, 4);
+ insn = extract_unsigned_integer (buf, 4, byte_order);
if (is_branch (insn, &immed, &ra))
return 0;
spu_frame_unwind_cache (struct frame_info *this_frame,
void **this_prologue_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct spu_unwind_cache *info;
struct spu_prologue_data data;
gdb_byte buf[16];
data.size = -1;
}
else
- spu_analyze_prologue (info->func, get_frame_pc (this_frame), &data);
-
+ spu_analyze_prologue (gdbarch, info->func, get_frame_pc (this_frame),
+ &data);
/* If successful, use prologue analysis data. */
if (data.size != -1 && data.cfa_reg != -1)
/* Determine CFA via unwound CFA_REG plus CFA_OFFSET. */
get_frame_register (this_frame, data.cfa_reg, buf);
- cfa = extract_unsigned_integer (buf, 4) + data.cfa_offset;
+ cfa = extract_unsigned_integer (buf, 4, byte_order) + data.cfa_offset;
/* Call-saved register slots. */
for (i = 0; i < SPU_NUM_GPRS; i++)
/* Get the backchain. */
reg = get_frame_register_unsigned (this_frame, SPU_SP_REGNUM);
- status = safe_read_memory_integer (reg, 4, &backchain);
+ status = safe_read_memory_integer (reg, 4, byte_order, &backchain);
/* A zero backchain terminates the frame chain. Also, sanity
check against the local store size limit. */
slot 1 contains the partition number of the overlay section to
be returned to, and slot 2 contains the return address within
that section. Return the latter address in that case. */
- if (extract_unsigned_integer (buf + 8, 4) != 0)
+ if (extract_unsigned_integer (buf + 8, 4, byte_order) != 0)
trad_frame_set_value (info->saved_regs, SPU_PC_REGNUM,
- extract_unsigned_integer (buf + 8, 4));
+ extract_unsigned_integer (buf + 8, 4, byte_order));
else
trad_frame_set_value (info->saved_regs, SPU_PC_REGNUM,
- extract_unsigned_integer (buf, 4));
+ extract_unsigned_integer (buf, 4, byte_order));
return info;
}
int nargs, struct value **args, CORE_ADDR sp,
int struct_return, CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR sp_delta;
int i;
int regnum = SPU_ARG1_REGNUM;
/* Set the return address. */
memset (buf, 0, sizeof buf);
- store_unsigned_integer (buf, 4, bp_addr);
+ store_unsigned_integer (buf, 4, byte_order, bp_addr);
regcache_cooked_write (regcache, SPU_LR_REGNUM, buf);
/* If STRUCT_RETURN is true, then the struct return address (in
if (struct_return)
{
memset (buf, 0, sizeof buf);
- store_unsigned_integer (buf, 4, struct_addr);
+ store_unsigned_integer (buf, 4, byte_order, struct_addr);
regcache_cooked_write (regcache, regnum++, buf);
}
target_write_memory (sp, buf, 16);
/* Finally, update all slots of the SP register. */
- sp_delta = sp - extract_unsigned_integer (buf, 4);
+ sp_delta = sp - extract_unsigned_integer (buf, 4, byte_order);
for (i = 0; i < 4; i++)
{
- CORE_ADDR sp_slot = extract_unsigned_integer (buf + 4*i, 4);
- store_unsigned_integer (buf + 4*i, 4, sp_slot + sp_delta);
+ CORE_ADDR sp_slot = extract_unsigned_integer (buf + 4*i, 4, byte_order);
+ store_unsigned_integer (buf + 4*i, 4, byte_order, sp_slot + sp_delta);
}
regcache_cooked_write (regcache, SPU_RAW_SP_REGNUM, buf);
spu_software_single_step (struct frame_info *frame)
{
struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR pc, next_pc;
unsigned int insn;
int offset, reg;
if (target_read_memory (pc, buf, 4))
return 1;
- insn = extract_unsigned_integer (buf, 4);
+ insn = extract_unsigned_integer (buf, 4, byte_order);
/* Next sequential instruction is at PC + 4, except if the current
instruction is a PPE-assisted call, in which case it is at PC + 8.
else if (reg != -1)
{
get_frame_register_bytes (frame, reg, 0, 4, buf);
- target += extract_unsigned_integer (buf, 4) & -4;
+ target += extract_unsigned_integer (buf, 4, byte_order) & -4;
}
target = target & (SPU_LS_SIZE - 1);
static int
spu_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
CORE_ADDR jb_addr;
/* Jump buffer is pointed to by the argument register $r3. */
get_frame_register_bytes (frame, SPU_ARG1_REGNUM, 0, 4, buf);
- jb_addr = extract_unsigned_integer (buf, 4);
+ jb_addr = extract_unsigned_integer (buf, 4, byte_order);
if (target_read_memory (jb_addr, buf, 4))
return 0;
- *pc = extract_unsigned_integer (buf, 4);
+ *pc = extract_unsigned_integer (buf, 4, byte_order);
return 1;
}
static struct spu_overlay_table *
spu_get_overlay_table (struct objfile *objfile)
{
+ enum bfd_endian byte_order = bfd_big_endian (objfile->obfd)?
+ BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
struct minimal_symbol *ovly_table_msym, *ovly_buf_table_msym;
CORE_ADDR ovly_table_base, ovly_buf_table_base;
unsigned ovly_table_size, ovly_buf_table_size;
for (i = 0; i < ovly_table_size / 16; i++)
{
- CORE_ADDR vma = extract_unsigned_integer (ovly_table + 16*i + 0, 4);
- CORE_ADDR size = extract_unsigned_integer (ovly_table + 16*i + 4, 4);
- CORE_ADDR pos = extract_unsigned_integer (ovly_table + 16*i + 8, 4);
- CORE_ADDR buf = extract_unsigned_integer (ovly_table + 16*i + 12, 4);
+ CORE_ADDR vma = extract_unsigned_integer (ovly_table + 16*i + 0,
+ 4, byte_order);
+ CORE_ADDR size = extract_unsigned_integer (ovly_table + 16*i + 4,
+ 4, byte_order);
+ CORE_ADDR pos = extract_unsigned_integer (ovly_table + 16*i + 8,
+ 4, byte_order);
+ CORE_ADDR buf = extract_unsigned_integer (ovly_table + 16*i + 12,
+ 4, byte_order);
if (buf == 0 || (buf - 1) * 4 >= ovly_buf_table_size)
continue;
static void
spu_overlay_update_osect (struct obj_section *osect)
{
+ enum bfd_endian byte_order = bfd_big_endian (osect->objfile->obfd)?
+ BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
struct spu_overlay_table *ovly_table;
CORE_ADDR val;
if (ovly_table->mapped_ptr == 0)
return;
- val = read_memory_unsigned_integer (ovly_table->mapped_ptr, 4);
+ val = read_memory_unsigned_integer (ovly_table->mapped_ptr, 4, byte_order);
osect->ovly_mapped = (val == ovly_table->mapped_val);
}
info_spu_signal_command (char *args, int from_tty)
{
struct frame_info *frame = get_selected_frame (NULL);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST signal1 = 0;
ULONGEST signal1_type = 0;
int signal1_pending = 0;
LONGEST len;
int rc, id;
- if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
error (_("\"info spu\" is only supported on the SPU architecture."));
id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
error (_("Could not read signal1."));
else if (len == 4)
{
- signal1 = extract_unsigned_integer (buf, 4);
+ signal1 = extract_unsigned_integer (buf, 4, byte_order);
signal1_pending = 1;
}
error (_("Could not read signal2."));
else if (len == 4)
{
- signal2 = extract_unsigned_integer (buf, 4);
+ signal2 = extract_unsigned_integer (buf, 4, byte_order);
signal2_pending = 1;
}
}
static void
-info_spu_mailbox_list (gdb_byte *buf, int nr,
+info_spu_mailbox_list (gdb_byte *buf, int nr, enum bfd_endian byte_order,
const char *field, const char *msg)
{
struct cleanup *chain;
struct cleanup *val_chain;
ULONGEST val;
val_chain = make_cleanup_ui_out_tuple_begin_end (uiout, "mbox");
- val = extract_unsigned_integer (buf + 4*i, 4);
+ val = extract_unsigned_integer (buf + 4*i, 4, byte_order);
ui_out_field_fmt (uiout, field, "0x%s", phex (val, 4));
do_cleanups (val_chain);
info_spu_mailbox_command (char *args, int from_tty)
{
struct frame_info *frame = get_selected_frame (NULL);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct cleanup *chain;
char annex[32];
gdb_byte buf[1024];
LONGEST len;
int i, id;
- if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
error (_("\"info spu\" is only supported on the SPU architecture."));
id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
if (len < 0)
error (_("Could not read mbox_info."));
- info_spu_mailbox_list (buf, len / 4, "mbox", "SPU Outbound Mailbox");
+ info_spu_mailbox_list (buf, len / 4, byte_order,
+ "mbox", "SPU Outbound Mailbox");
xsnprintf (annex, sizeof annex, "%d/ibox_info", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
if (len < 0)
error (_("Could not read ibox_info."));
- info_spu_mailbox_list (buf, len / 4, "ibox", "SPU Outbound Interrupt Mailbox");
+ info_spu_mailbox_list (buf, len / 4, byte_order,
+ "ibox", "SPU Outbound Interrupt Mailbox");
xsnprintf (annex, sizeof annex, "%d/wbox_info", id);
len = target_read (¤t_target, TARGET_OBJECT_SPU, annex,
if (len < 0)
error (_("Could not read wbox_info."));
- info_spu_mailbox_list (buf, len / 4, "wbox", "SPU Inbound Mailbox");
+ info_spu_mailbox_list (buf, len / 4, byte_order,
+ "wbox", "SPU Inbound Mailbox");
do_cleanups (chain);
}
}
static void
-info_spu_dma_cmdlist (gdb_byte *buf, int nr)
+info_spu_dma_cmdlist (gdb_byte *buf, int nr, enum bfd_endian byte_order)
{
static char *spu_mfc_opcode[256] =
{
if (done & (1 << (nr - 1 - j)))
continue;
- mfc_cq_dw3 = extract_unsigned_integer (buf + 32*j + 24, 8);
+ mfc_cq_dw3
+ = extract_unsigned_integer (buf + 32*j + 24,8, byte_order);
if (!spu_mfc_get_bitfield (mfc_cq_dw3, 16, 16))
continue;
/* Decode contents of MFC Command Queue Context Save/Restore Registers.
See "Cell Broadband Engine Registers V1.3", section 3.3.2.1. */
- mfc_cq_dw0 = extract_unsigned_integer (buf + 32*seq[i], 8);
- mfc_cq_dw1 = extract_unsigned_integer (buf + 32*seq[i] + 8, 8);
- mfc_cq_dw2 = extract_unsigned_integer (buf + 32*seq[i] + 16, 8);
+ mfc_cq_dw0
+ = extract_unsigned_integer (buf + 32*seq[i], 8, byte_order);
+ mfc_cq_dw1
+ = extract_unsigned_integer (buf + 32*seq[i] + 8, 8, byte_order);
+ mfc_cq_dw2
+ = extract_unsigned_integer (buf + 32*seq[i] + 16, 8, byte_order);
list_lsa = spu_mfc_get_bitfield (mfc_cq_dw0, 0, 14);
list_size = spu_mfc_get_bitfield (mfc_cq_dw0, 15, 26);
info_spu_dma_command (char *args, int from_tty)
{
struct frame_info *frame = get_selected_frame (NULL);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST dma_info_type;
ULONGEST dma_info_mask;
ULONGEST dma_info_status;
if (len <= 0)
error (_("Could not read dma_info."));
- dma_info_type = extract_unsigned_integer (buf, 8);
- dma_info_mask = extract_unsigned_integer (buf + 8, 8);
- dma_info_status = extract_unsigned_integer (buf + 16, 8);
- dma_info_stall_and_notify = extract_unsigned_integer (buf + 24, 8);
- dma_info_atomic_command_status = extract_unsigned_integer (buf + 32, 8);
+ dma_info_type
+ = extract_unsigned_integer (buf, 8, byte_order);
+ dma_info_mask
+ = extract_unsigned_integer (buf + 8, 8, byte_order);
+ dma_info_status
+ = extract_unsigned_integer (buf + 16, 8, byte_order);
+ dma_info_stall_and_notify
+ = extract_unsigned_integer (buf + 24, 8, byte_order);
+ dma_info_atomic_command_status
+ = extract_unsigned_integer (buf + 32, 8, byte_order);
chain = make_cleanup_ui_out_tuple_begin_end (uiout, "SPUInfoDMA");
printf_filtered ("\n");
}
- info_spu_dma_cmdlist (buf + 40, 16);
+ info_spu_dma_cmdlist (buf + 40, 16, byte_order);
do_cleanups (chain);
}
info_spu_proxydma_command (char *args, int from_tty)
{
struct frame_info *frame = get_selected_frame (NULL);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
ULONGEST dma_info_type;
ULONGEST dma_info_mask;
ULONGEST dma_info_status;
LONGEST len;
int i, id;
- if (gdbarch_bfd_arch_info (get_frame_arch (frame))->arch != bfd_arch_spu)
+ if (gdbarch_bfd_arch_info (gdbarch)->arch != bfd_arch_spu)
error (_("\"info spu\" is only supported on the SPU architecture."));
id = get_frame_register_unsigned (frame, SPU_ID_REGNUM);
if (len <= 0)
error (_("Could not read proxydma_info."));
- dma_info_type = extract_unsigned_integer (buf, 8);
- dma_info_mask = extract_unsigned_integer (buf + 8, 8);
- dma_info_status = extract_unsigned_integer (buf + 16, 8);
+ dma_info_type = extract_unsigned_integer (buf, 8, byte_order);
+ dma_info_mask = extract_unsigned_integer (buf + 8, 8, byte_order);
+ dma_info_status = extract_unsigned_integer (buf + 16, 8, byte_order);
chain = make_cleanup_ui_out_tuple_begin_end (uiout, "SPUInfoProxyDMA");
printf_filtered ("\n");
}
- info_spu_dma_cmdlist (buf + 24, 8);
+ info_spu_dma_cmdlist (buf + 24, 8, byte_order);
do_cleanups (chain);
}
print_frame_nameless_args (struct frame_info *frame, long start, int num,
int first, struct ui_file *stream)
{
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
CORE_ADDR argsaddr;
long arg_value;
argsaddr = get_frame_args_address (frame);
if (!argsaddr)
return;
- arg_value = read_memory_integer (argsaddr + start, sizeof (int));
+ arg_value = read_memory_integer (argsaddr + start,
+ sizeof (int), byte_order);
if (!first)
fprintf_filtered (stream, ", ");
fprintf_filtered (stream, "%ld", arg_value);
&realnum, NULL);
if (!optimized && lval == not_lval)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ int sp_size = register_size (gdbarch, gdbarch_sp_regnum (gdbarch));
gdb_byte value[MAX_REGISTER_SIZE];
CORE_ADDR sp;
frame_register_unwind (fi, gdbarch_sp_regnum (gdbarch),
/* NOTE: cagney/2003-05-22: This is assuming that the
stack pointer was packed as an unsigned integer. That
may or may not be valid. */
- sp = extract_unsigned_integer (value,
- register_size (gdbarch,
- gdbarch_sp_regnum (gdbarch)));
+ sp = extract_unsigned_integer (value, sp_size, byte_order);
printf_filtered (" Previous frame's sp is ");
fputs_filtered (paddress (gdbarch, sp), gdb_stdout);
printf_filtered ("\n");
static void simple_free_overlay_table (void);
-static void read_target_long_array (CORE_ADDR, unsigned int *, int, int);
+static void read_target_long_array (CORE_ADDR, unsigned int *, int, int,
+ enum bfd_endian);
static int simple_read_overlay_table (void);
Convert to host order. int LEN is number of ints */
static void
read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
- int len, int size)
+ int len, int size, enum bfd_endian byte_order)
{
/* FIXME (alloca): Not safe if array is very large. */
gdb_byte *buf = alloca (len * size);
read_memory (memaddr, buf, len * size);
for (i = 0; i < len; i++)
- myaddr[i] = extract_unsigned_integer (size * i + buf, size);
+ myaddr[i] = extract_unsigned_integer (size * i + buf, size, byte_order);
}
/* Find and grab a copy of the target _ovly_table
struct minimal_symbol *novlys_msym, *ovly_table_msym;
struct gdbarch *gdbarch;
int word_size;
+ enum bfd_endian byte_order;
simple_free_overlay_table ();
novlys_msym = lookup_minimal_symbol ("_novlys", NULL, NULL);
gdbarch = get_objfile_arch (msymbol_objfile (ovly_table_msym));
word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+ byte_order = gdbarch_byte_order (gdbarch);
- cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (novlys_msym), 4);
+ cache_novlys = read_memory_integer (SYMBOL_VALUE_ADDRESS (novlys_msym),
+ 4, byte_order);
cache_ovly_table
= (void *) xmalloc (cache_novlys * sizeof (*cache_ovly_table));
cache_ovly_table_base = SYMBOL_VALUE_ADDRESS (ovly_table_msym);
read_target_long_array (cache_ovly_table_base,
(unsigned int *) cache_ovly_table,
- cache_novlys * 4, word_size);
+ cache_novlys * 4, word_size, byte_order);
return 1; /* SUCCESS */
}
simple_read_overlay_region_table (void)
{
struct minimal_symbol *msym;
+ struct gdbarch *gdbarch;
+ int word_size;
+ enum bfd_endian byte_order;
simple_free_overlay_region_table ();
msym = lookup_minimal_symbol ("_novly_regions", NULL, NULL);
- if (msym != NULL)
- cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym), 4);
- else
+ if (msym == NULL)
return 0; /* failure */
+
+ gdbarch = get_objfile_arch (msymbol_objfile (msym));
+ word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+ byte_order = gdbarch_byte_order (gdbarch);
+
+ cache_novly_regions = read_memory_integer (SYMBOL_VALUE_ADDRESS (msym),
+ 4, byte_order);
+
cache_ovly_region_table = (void *) xmalloc (cache_novly_regions * 12);
if (cache_ovly_region_table != NULL)
{
msym = lookup_minimal_symbol ("_ovly_region_table", NULL, NULL);
if (msym != NULL)
{
- struct gdbarch *gdbarch = get_objfile_arch (msymbol_objfile (msym));
- int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
cache_ovly_region_table_base = SYMBOL_VALUE_ADDRESS (msym);
read_target_long_array (cache_ovly_region_table_base,
(unsigned int *) cache_ovly_region_table,
- cache_novly_regions * 3, word_size);
+ cache_novly_regions * 3,
+ word_size, byte_order);
}
else
return 0; /* failure */
asection *bsect = osect->the_bfd_section;
struct gdbarch *gdbarch = get_objfile_arch (osect->objfile);
int word_size = gdbarch_long_bit (gdbarch) / TARGET_CHAR_BIT;
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
size = bfd_get_section_size (osect->the_bfd_section);
for (i = 0; i < cache_novlys; i++)
{
read_target_long_array (cache_ovly_table_base + i * word_size,
(unsigned int *) cache_ovly_table[i],
- 4, word_size);
+ 4, word_size, byte_order);
if (cache_ovly_table[i][VMA] == bfd_section_vma (obfd, bsect)
&& cache_ovly_table[i][LMA] == bfd_section_lma (obfd, bsect)
/* && cache_ovly_table[i][SIZE] == size */ )
ULONGEST
get_target_memory_unsigned (struct target_ops *ops,
- CORE_ADDR addr, int len)
+ CORE_ADDR addr, int len, enum bfd_endian byte_order)
{
gdb_byte buf[sizeof (ULONGEST)];
gdb_assert (len <= sizeof (buf));
get_target_memory (ops, addr, buf, len);
- return extract_unsigned_integer (buf, len);
+ return extract_unsigned_integer (buf, len, byte_order);
}
static void
fprintf_unfiltered (gdb_stdlog, "(%d)", regno);
if (regno >= 0 && regno < gdbarch_num_regs (gdbarch))
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i, size = register_size (gdbarch, regno);
unsigned char buf[MAX_REGISTER_SIZE];
regcache_raw_collect (regcache, regno, buf);
}
if (size <= sizeof (LONGEST))
{
- ULONGEST val = extract_unsigned_integer (buf, size);
+ ULONGEST val = extract_unsigned_integer (buf, size, byte_order);
fprintf_unfiltered (gdb_stdlog, " %s %s",
core_addr_to_string_nz (val), plongest (val));
}
extern void get_target_memory (struct target_ops *ops, CORE_ADDR addr,
gdb_byte *buf, LONGEST len);
extern ULONGEST get_target_memory_unsigned (struct target_ops *ops,
- CORE_ADDR addr, int len);
+ CORE_ADDR addr, int len,
+ enum bfd_endian byte_order);
\f
struct thread_info; /* fwd decl for parameter list below: */
tramp_frame_start (const struct tramp_frame *tramp,
struct frame_info *this_frame, CORE_ADDR pc)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int ti;
/* Search through the trampoline for one that matches the
instruction sequence around PC. */
func + i * tramp->insn_size,
buf, tramp->insn_size))
break;
- insn = extract_unsigned_integer (buf, tramp->insn_size);
+ insn = extract_unsigned_integer (buf, tramp->insn_size, byte_order);
if (tramp->insn[i].bytes != (insn & tramp->insn[i].mask))
break;
}
prologue. */
static CORE_ADDR
-v850_analyze_prologue (CORE_ADDR func_addr, CORE_ADDR pc,
+v850_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR func_addr, CORE_ADDR pc,
struct v850_frame_cache *pi, ULONGEST ctbp)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR prologue_end, current_pc;
struct pifsr pifsrs[E_NUM_REGS + 1];
struct pifsr *pifsr, *pifsr_tmp;
int insn;
int insn2 = -1; /* dummy value */
- insn = read_memory_integer (current_pc, 2);
+ insn = read_memory_integer (current_pc, 2, byte_order);
current_pc += 2;
if ((insn & 0x0780) >= 0x0600) /* Four byte instruction? */
{
- insn2 = read_memory_integer (current_pc, 2);
+ insn2 = read_memory_integer (current_pc, 2, byte_order);
current_pc += 2;
}
save_pc = current_pc;
save_end = prologue_end;
regsave_func_p = 1;
- current_pc = ctbp + (read_memory_unsigned_integer (adr, 2) & 0xffff);
+ current_pc = ctbp + (read_memory_unsigned_integer (adr, 2, byte_order)
+ & 0xffff);
prologue_end = (current_pc
+ (2 * 3) /* prepare list2,imm5,sp/imm */
+ 4 /* ctret */
int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argreg;
int argnum;
int len = 0;
if (!v850_type_is_scalar (value_type (*args))
&& TYPE_LENGTH (value_type (*args)) > E_MAX_RETTYPE_SIZE_IN_REGS)
{
- store_unsigned_integer (valbuf, 4, value_address (*args));
+ store_unsigned_integer (valbuf, 4, byte_order,
+ value_address (*args));
len = 4;
val = valbuf;
}
{
CORE_ADDR regval;
- regval = extract_unsigned_integer (val, v850_reg_size);
+ regval = extract_unsigned_integer (val, v850_reg_size, byte_order);
regcache_cooked_write_unsigned (regcache, argreg, regval);
len -= v850_reg_size;
v850_extract_return_value (struct type *type, struct regcache *regcache,
gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
if (len <= v850_reg_size)
ULONGEST val;
regcache_cooked_read_unsigned (regcache, E_V0_REGNUM, &val);
- store_unsigned_integer (valbuf, len, val);
+ store_unsigned_integer (valbuf, len, byte_order, val);
}
else if (len <= 2 * v850_reg_size)
{
v850_store_return_value (struct type *type, struct regcache *regcache,
const gdb_byte *valbuf)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int len = TYPE_LENGTH (type);
if (len <= v850_reg_size)
- regcache_cooked_write_unsigned (regcache, E_V0_REGNUM,
- extract_unsigned_integer (valbuf, len));
+ regcache_cooked_write_unsigned
+ (regcache, E_V0_REGNUM,
+ extract_unsigned_integer (valbuf, len, byte_order));
else if (len <= 2 * v850_reg_size)
{
int i, regnum = E_V0_REGNUM;
static struct v850_frame_cache *
v850_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct v850_frame_cache *cache;
CORE_ADDR current_pc;
int i;
{
ULONGEST ctbp;
ctbp = get_frame_register_unsigned (this_frame, E_CTBP_REGNUM);
- v850_analyze_prologue (cache->pc, current_pc, cache, ctbp);
+ v850_analyze_prologue (gdbarch, cache->pc, current_pc, cache, ctbp);
}
if (!cache->uses_fp)
other types if one of them is not decimal floating point. */
static void
value_args_as_decimal (struct value *arg1, struct value *arg2,
- gdb_byte *x, int *len_x, gdb_byte *y, int *len_y)
+ gdb_byte *x, int *len_x, enum bfd_endian *byte_order_x,
+ gdb_byte *y, int *len_y, enum bfd_endian *byte_order_y)
{
struct type *type1, *type2;
if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
{
+ *byte_order_x = gdbarch_byte_order (get_type_arch (type1));
*len_x = TYPE_LENGTH (type1);
memcpy (x, value_contents (arg1), *len_x);
}
else if (is_integral_type (type1))
{
+ *byte_order_x = gdbarch_byte_order (get_type_arch (type2));
*len_x = TYPE_LENGTH (type2);
- decimal_from_integral (arg1, x, *len_x);
+ decimal_from_integral (arg1, x, *len_x, *byte_order_x);
}
else
error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
if (TYPE_CODE (type2) == TYPE_CODE_DECFLOAT)
{
+ *byte_order_y = gdbarch_byte_order (get_type_arch (type2));
*len_y = TYPE_LENGTH (type2);
memcpy (y, value_contents (arg2), *len_y);
}
else if (is_integral_type (type2))
{
+ *byte_order_y = gdbarch_byte_order (get_type_arch (type1));
*len_y = TYPE_LENGTH (type1);
- decimal_from_integral (arg2, y, *len_y);
+ decimal_from_integral (arg2, y, *len_y, *byte_order_y);
}
else
error (_("Don't know how to convert from %s to %s."), TYPE_NAME (type1),
{
struct type *v_type;
int len_v1, len_v2, len_v;
+ enum bfd_endian byte_order_v1, byte_order_v2, byte_order_v;
gdb_byte v1[16], v2[16];
gdb_byte v[16];
result_type = type1;
len_v = TYPE_LENGTH (result_type);
+ byte_order_v = gdbarch_byte_order (get_type_arch (result_type));
- value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+ value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+ v2, &len_v2, &byte_order_v2);
switch (op)
{
case BINOP_MUL:
case BINOP_DIV:
case BINOP_EXP:
- decimal_binop (op, v1, len_v1, v2, len_v2, v, len_v);
+ decimal_binop (op, v1, len_v1, byte_order_v1,
+ v2, len_v2, byte_order_v2,
+ v, len_v, byte_order_v);
break;
default:
val = allocate_value (result_type);
store_signed_integer (value_contents_raw (val),
TYPE_LENGTH (result_type),
+ gdbarch_byte_order (get_type_arch (result_type)),
v);
}
else
val = allocate_value (result_type);
store_unsigned_integer (value_contents_raw (val),
TYPE_LENGTH (value_type (val)),
+ gdbarch_byte_order
+ (get_type_arch (result_type)),
v);
}
else
val = allocate_value (result_type);
store_signed_integer (value_contents_raw (val),
TYPE_LENGTH (value_type (val)),
+ gdbarch_byte_order
+ (get_type_arch (result_type)),
v);
}
}
if (TYPE_CODE (type1) == TYPE_CODE_FLT)
return 0 == value_as_double (arg1);
else if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
- return decimal_is_zero (value_contents (arg1), TYPE_LENGTH (type1));
+ return decimal_is_zero (value_contents (arg1), TYPE_LENGTH (type1),
+ gdbarch_byte_order (get_type_arch (type1)));
len = TYPE_LENGTH (type1);
p = value_contents (arg1);
{
gdb_byte v1[16], v2[16];
int len_v1, len_v2;
+ enum bfd_endian byte_order_v1, byte_order_v2;
- value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+ value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+ v2, &len_v2, &byte_order_v2);
- return decimal_compare (v1, len_v1, v2, len_v2) == 0;
+ return decimal_compare (v1, len_v1, byte_order_v1,
+ v2, len_v2, byte_order_v2) == 0;
}
/* FIXME: Need to promote to either CORE_ADDR or LONGEST, whichever
{
gdb_byte v1[16], v2[16];
int len_v1, len_v2;
+ enum bfd_endian byte_order_v1, byte_order_v2;
- value_args_as_decimal (arg1, arg2, v1, &len_v1, v2, &len_v2);
+ value_args_as_decimal (arg1, arg2, v1, &len_v1, &byte_order_v1,
+ v2, &len_v2, &byte_order_v2);
- return decimal_compare (v1, len_v1, v2, len_v2) == -1;
+ return decimal_compare (v1, len_v1, byte_order_v1,
+ v2, len_v2, byte_order_v2) == -1;
}
else if (code1 == TYPE_CODE_PTR && code2 == TYPE_CODE_PTR)
return value_as_address (arg1) < value_as_address (arg2);
if (index < low_bound || index > high_bound)
return -1;
rel_index = index - low_bound;
- word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1);
+ word = extract_unsigned_integer (valaddr + (rel_index / TARGET_CHAR_BIT), 1,
+ gdbarch_byte_order (gdbarch));
rel_index %= TARGET_CHAR_BIT;
if (gdbarch_bits_big_endian (gdbarch))
rel_index = TARGET_CHAR_BIT - 1 - rel_index;
return value_from_double (type, value_as_double (arg2));
else if (code1 == TYPE_CODE_DECFLOAT && scalar)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
int dec_len = TYPE_LENGTH (type);
gdb_byte dec[16];
if (code2 == TYPE_CODE_FLT)
- decimal_from_floating (arg2, dec, dec_len);
+ decimal_from_floating (arg2, dec, dec_len, byte_order);
else if (code2 == TYPE_CODE_DECFLOAT)
decimal_convert (value_contents (arg2), TYPE_LENGTH (type2),
- dec, dec_len);
+ byte_order, dec, dec_len, byte_order);
else
/* The only option left is an integral type. */
- decimal_from_integral (arg2, dec, dec_len);
+ decimal_from_integral (arg2, dec, dec_len, byte_order);
return value_from_decfloat (type, dec);
}
sees a cast as a simple reinterpretation of the pointer's
bits. */
if (code2 == TYPE_CODE_PTR)
- longest = extract_unsigned_integer (value_contents (arg2),
- TYPE_LENGTH (type2));
+ longest = extract_unsigned_integer
+ (value_contents (arg2), TYPE_LENGTH (type2),
+ gdbarch_byte_order (get_type_arch (type2)));
else
longest = value_as_long (arg2);
return value_from_longest (type, convert_to_boolean ?
if (TYPE_CODE (type1) == TYPE_CODE_DECFLOAT)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
gdb_byte v[16];
- decimal_from_string (v, TYPE_LENGTH (type), "1");
+ decimal_from_string (v, TYPE_LENGTH (type), byte_order, "1");
val = value_from_decfloat (type, v);
}
else if (TYPE_CODE (type1) == TYPE_CODE_FLT)
if (TYPE_UNSIGNED (type)
&& extract_long_unsigned_integer (valaddr, TYPE_LENGTH (type),
- &val))
+ byte_order, &val))
{
print_longest (stream, 'u', 0, val);
}
print_decimal_floating (const gdb_byte *valaddr, struct type *type,
struct ui_file *stream)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
char decstr[MAX_DECIMAL_STRING];
unsigned len = TYPE_LENGTH (type);
- decimal_to_string (valaddr, len, decstr);
+ decimal_to_string (valaddr, len, byte_order, decstr);
fputs_filtered (decstr, stream);
return;
}
int
read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
- gdb_byte **buffer, int *bytes_read)
+ enum bfd_endian byte_order, gdb_byte **buffer, int *bytes_read)
{
int found_nul; /* Non-zero if we found the nul char. */
int errcode; /* Errno returned from bad reads. */
{
unsigned long c;
- c = extract_unsigned_integer (bufptr, width);
+ c = extract_unsigned_integer (bufptr, width, byte_order);
addr += width;
bufptr += width;
if (c == 0)
gdb_byte *buffer = NULL; /* Dynamically growable fetch buffer. */
struct cleanup *old_chain = NULL; /* Top of the old cleanup chain. */
struct gdbarch *gdbarch = get_type_arch (elttype);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int width = TYPE_LENGTH (elttype);
/* First we need to figure out the limit on the number of characters we are
fetchlimit = (len == -1 ? options->print_max : min (len, options->print_max));
- errcode = read_string (addr, len, width, fetchlimit, &buffer, &bytes_read);
+ errcode = read_string (addr, len, width, fetchlimit, byte_order,
+ &buffer, &bytes_read);
old_chain = make_cleanup (xfree, buffer);
addr += bytes_read;
terminated early due to an error or finding a null char when LEN is -1. */
/* Determine found_nul by looking at the last character read. */
- found_nul = extract_unsigned_integer (buffer + bytes_read - width, width) == 0;
-
+ found_nul = extract_unsigned_integer (buffer + bytes_read - width, width,
+ byte_order) == 0;
if (len == -1 && !found_nul)
{
gdb_byte *peekbuf;
peekbuf = (gdb_byte *) alloca (width);
if (target_read_memory (addr, peekbuf, width) == 0
- && extract_unsigned_integer (peekbuf, width) != 0)
+ && extract_unsigned_integer (peekbuf, width, byte_order) != 0)
force_ellipsis = 1;
}
else if ((len >= 0 && errcode != 0) || (len > bytes_read / width))
const gdb_byte *, unsigned int, enum bfd_endian);
int read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
- gdb_byte **buffer, int *bytes_read);
+ enum bfd_endian byte_order, gdb_byte **buffer,
+ int *bytes_read);
#endif
LONGEST
unpack_long (struct type *type, const gdb_byte *valaddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
enum type_code code = TYPE_CODE (type);
int len = TYPE_LENGTH (type);
int nosign = TYPE_UNSIGNED (type);
case TYPE_CODE_RANGE:
case TYPE_CODE_MEMBERPTR:
if (nosign)
- return extract_unsigned_integer (valaddr, len);
+ return extract_unsigned_integer (valaddr, len, byte_order);
else
- return extract_signed_integer (valaddr, len);
+ return extract_signed_integer (valaddr, len, byte_order);
case TYPE_CODE_FLT:
return extract_typed_floating (valaddr, type);
case TYPE_CODE_DECFLOAT:
/* libdecnumber has a function to convert from decimal to integer, but
it doesn't work when the decimal number has a fractional part. */
- return decimal_to_doublest (valaddr, len);
+ return decimal_to_doublest (valaddr, len, byte_order);
case TYPE_CODE_PTR:
case TYPE_CODE_REF:
DOUBLEST
unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
enum type_code code;
int len;
int nosign;
return extract_typed_floating (valaddr, type);
}
else if (code == TYPE_CODE_DECFLOAT)
- return decimal_to_doublest (valaddr, len);
+ return decimal_to_doublest (valaddr, len, byte_order);
else if (nosign)
{
/* Unsigned -- be sure we compensate for signed LONGEST. */
LONGEST
unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
ULONGEST val;
ULONGEST valmask;
int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
int lsbcount;
struct type *field_type;
- val = extract_unsigned_integer (valaddr + bitpos / 8, sizeof (val));
+ val = extract_unsigned_integer (valaddr + bitpos / 8,
+ sizeof (val), byte_order);
field_type = TYPE_FIELD_TYPE (type, fieldno);
CHECK_TYPEDEF (field_type);
modify_field (struct type *type, gdb_byte *addr,
LONGEST fieldval, int bitpos, int bitsize)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
ULONGEST oword;
ULONGEST mask = (ULONGEST) -1 >> (8 * sizeof (ULONGEST) - bitsize);
fieldval &= mask;
}
- oword = extract_unsigned_integer (addr, sizeof oword);
+ oword = extract_unsigned_integer (addr, sizeof oword, byte_order);
/* Shifting for bit field depends on endianness of the target machine. */
if (gdbarch_bits_big_endian (get_type_arch (type)))
oword &= ~(mask << bitpos);
oword |= fieldval << bitpos;
- store_unsigned_integer (addr, sizeof oword, oword);
+ store_unsigned_integer (addr, sizeof oword, byte_order, oword);
}
\f
/* Pack NUM into BUF using a target format of TYPE. */
void
pack_long (gdb_byte *buf, struct type *type, LONGEST num)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
int len;
type = check_typedef (type);
case TYPE_CODE_BOOL:
case TYPE_CODE_RANGE:
case TYPE_CODE_MEMBERPTR:
- store_signed_integer (buf, len, num);
+ store_signed_integer (buf, len, byte_order, num);
break;
case TYPE_CODE_REF:
vax_store_arguments (struct regcache *regcache, int nargs,
struct value **args, CORE_ADDR sp)
{
+ struct gdbarch *gdbarch = get_regcache_arch (regcache);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
gdb_byte buf[4];
int count = 0;
int i;
/* Push argument count. */
sp -= 4;
- store_unsigned_integer (buf, 4, count);
+ store_unsigned_integer (buf, 4, byte_order, count);
write_memory (sp, buf, 4);
/* Update the argument pointer. */
- store_unsigned_integer (buf, 4, sp);
+ store_unsigned_integer (buf, 4, byte_order, sp);
regcache_cooked_write (regcache, VAX_AP_REGNUM, buf);
return sp;
struct value **args, CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR fp = sp;
gdb_byte buf[4];
/* Store return address in the PC slot. */
sp -= 4;
- store_unsigned_integer (buf, 4, bp_addr);
+ store_unsigned_integer (buf, 4, byte_order, bp_addr);
write_memory (sp, buf, 4);
/* Store the (fake) frame pointer in the FP slot. */
sp -= 4;
- store_unsigned_integer (buf, 4, fp);
+ store_unsigned_integer (buf, 4, byte_order, fp);
write_memory (sp, buf, 4);
/* Skip the AP slot. */
/* Store register save mask and control bits. */
sp -= 4;
- store_unsigned_integer (buf, 4, 0);
+ store_unsigned_integer (buf, 4, byte_order, 0);
write_memory (sp, buf, 4);
/* Store condition handler. */
sp -= 4;
- store_unsigned_integer (buf, 4, 0);
+ store_unsigned_integer (buf, 4, byte_order, 0);
write_memory (sp, buf, 4);
/* Update the stack pointer and frame pointer. */
- store_unsigned_integer (buf, 4, sp);
+ store_unsigned_integer (buf, 4, byte_order, sp);
regcache_cooked_write (regcache, VAX_SP_REGNUM, buf);
regcache_cooked_write (regcache, VAX_FP_REGNUM, buf);
static CORE_ADDR
vax_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
{
- gdb_byte op = read_memory_unsigned_integer (pc, 1);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+ gdb_byte op = read_memory_unsigned_integer (pc, 1, byte_order);
if (op == 0x11)
pc += 2; /* skip brb */
if (op == 0x31)
pc += 3; /* skip brw */
if (op == 0xC2
- && (read_memory_unsigned_integer (pc + 2, 1)) == 0x5E)
+ && read_memory_unsigned_integer (pc + 2, 1, byte_order) == 0x5E)
pc += 3; /* skip subl2 */
if (op == 0x9E
- && (read_memory_unsigned_integer (pc + 1, 1)) == 0xAE
- && (read_memory_unsigned_integer (pc + 3, 1)) == 0x5E)
+ && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xAE
+ && read_memory_unsigned_integer (pc + 3, 1, byte_order) == 0x5E)
pc += 4; /* skip movab */
if (op == 0x9E
- && (read_memory_unsigned_integer (pc + 1, 1)) == 0xCE
- && (read_memory_unsigned_integer (pc + 4, 1)) == 0x5E)
+ && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xCE
+ && read_memory_unsigned_integer (pc + 4, 1, byte_order) == 0x5E)
pc += 5; /* skip movab */
if (op == 0x9E
- && (read_memory_unsigned_integer (pc + 1, 1)) == 0xEE
- && (read_memory_unsigned_integer (pc + 6, 1)) == 0x5E)
+ && read_memory_unsigned_integer (pc + 1, 1, byte_order) == 0xEE
+ && read_memory_unsigned_integer (pc + 6, 1, byte_order) == 0x5E)
pc += 7; /* skip movab */
return pc;
CORE_ADDR sp, int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR stack_dest = sp;
int argreg = E_1ST_ARG_REGNUM;
int i, j;
extract_unsigned_integer (val + j,
typelen - j ==
1 ? 1 :
- xstormy16_reg_size));
+ xstormy16_reg_size,
+ byte_order));
}
/* Align SP */
stack_dest += typelen + slacklen;
}
- store_unsigned_integer (buf, xstormy16_pc_size, bp_addr);
+ store_unsigned_integer (buf, xstormy16_pc_size, byte_order, bp_addr);
write_memory (stack_dest, buf, xstormy16_pc_size);
stack_dest += xstormy16_pc_size;
Returns the address of the first instruction after the prologue. */
static CORE_ADDR
-xstormy16_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
+xstormy16_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start_addr, CORE_ADDR end_addr,
struct xstormy16_frame_cache *cache,
struct frame_info *this_frame)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR next_addr;
ULONGEST inst, inst2;
LONGEST offset;
for (next_addr = start_addr;
next_addr < end_addr; next_addr += xstormy16_inst_size)
{
- inst = read_memory_unsigned_integer (next_addr, xstormy16_inst_size);
+ inst = read_memory_unsigned_integer (next_addr,
+ xstormy16_inst_size, byte_order);
inst2 = read_memory_unsigned_integer (next_addr + xstormy16_inst_size,
- xstormy16_inst_size);
+ xstormy16_inst_size, byte_order);
if (inst >= 0x0082 && inst <= 0x008d) /* push r2 .. push r13 */
{
memset (&cache, 0, sizeof cache);
/* Don't trust line number debug info in frameless functions. */
- plg_end = xstormy16_analyze_prologue (func_addr, func_end, &cache, NULL);
+ plg_end = xstormy16_analyze_prologue (gdbarch, func_addr, func_end,
+ &cache, NULL);
if (!cache.uses_fp)
return plg_end;
static int
xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR func_addr = 0, func_end = 0;
if (find_pc_partial_function (pc, NULL, &func_addr, &func_end))
/* Check if we're on a `ret' instruction. Otherwise it's
too dangerous to proceed. */
- inst = read_memory_unsigned_integer (addr, xstormy16_inst_size);
+ inst = read_memory_unsigned_integer (addr,
+ xstormy16_inst_size, byte_order);
if (inst != 0x0003)
return 0;
while ((addr -= xstormy16_inst_size) >= func_addr)
{
- inst = read_memory_unsigned_integer (addr, xstormy16_inst_size);
+ inst = read_memory_unsigned_integer (addr,
+ xstormy16_inst_size, byte_order);
if (inst >= 0x009a && inst <= 0x009d) /* pop r10...r13 */
continue;
if (inst == 0x305f || inst == 0x307f) /* dec r15, #0x1/#0x3 */
break;
inst2 = read_memory_unsigned_integer (addr - xstormy16_inst_size,
- xstormy16_inst_size);
+ xstormy16_inst_size, byte_order);
if (inst2 == 0x314f && inst >= 0x8000) /* add r15, neg. value */
{
addr -= xstormy16_inst_size;
/* Given a pointer to a jump table entry, return the address
of the function it jumps to. Return 0 if not found. */
static CORE_ADDR
-xstormy16_resolve_jmp_table_entry (CORE_ADDR faddr)
+xstormy16_resolve_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *faddr_sect = find_pc_section (faddr);
if (faddr_sect)
if (!target_read_memory (faddr, buf, sizeof buf))
{
- inst = extract_unsigned_integer (buf, xstormy16_inst_size);
+ inst = extract_unsigned_integer (buf,
+ xstormy16_inst_size, byte_order);
inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
- xstormy16_inst_size);
+ xstormy16_inst_size, byte_order);
addr = inst2 << 8 | (inst & 0xff);
return addr;
}
address of the corresponding jump table entry. Return 0 if
not found. */
static CORE_ADDR
-xstormy16_find_jmp_table_entry (CORE_ADDR faddr)
+xstormy16_find_jmp_table_entry (struct gdbarch *gdbarch, CORE_ADDR faddr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
struct obj_section *faddr_sect = find_pc_section (faddr);
if (faddr_sect)
if (target_read_memory (addr, buf, sizeof buf))
return 0;
- inst = extract_unsigned_integer (buf, xstormy16_inst_size);
+ inst = extract_unsigned_integer (buf,
+ xstormy16_inst_size, byte_order);
inst2 = extract_unsigned_integer (buf + xstormy16_inst_size,
- xstormy16_inst_size);
+ xstormy16_inst_size, byte_order);
faddr2 = inst2 << 8 | (inst & 0xff);
if (faddr == faddr2)
return addr;
static CORE_ADDR
xstormy16_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
- CORE_ADDR tmp = xstormy16_resolve_jmp_table_entry (pc);
+ struct gdbarch *gdbarch = get_frame_arch (frame);
+ CORE_ADDR tmp = xstormy16_resolve_jmp_table_entry (gdbarch, pc);
if (tmp && tmp != pc)
return tmp;
xstormy16_pointer_to_address (struct gdbarch *gdbarch,
struct type *type, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
- CORE_ADDR addr = extract_unsigned_integer (buf, TYPE_LENGTH (type));
+ CORE_ADDR addr
+ = extract_unsigned_integer (buf, TYPE_LENGTH (type), byte_order);
if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
{
- CORE_ADDR addr2 = xstormy16_resolve_jmp_table_entry (addr);
+ CORE_ADDR addr2 = xstormy16_resolve_jmp_table_entry (gdbarch, addr);
if (addr2)
addr = addr2;
}
xstormy16_address_to_pointer (struct gdbarch *gdbarch,
struct type *type, gdb_byte *buf, CORE_ADDR addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
enum type_code target = TYPE_CODE (TYPE_TARGET_TYPE (type));
if (target == TYPE_CODE_FUNC || target == TYPE_CODE_METHOD)
{
- CORE_ADDR addr2 = xstormy16_find_jmp_table_entry (addr);
+ CORE_ADDR addr2 = xstormy16_find_jmp_table_entry (gdbarch, addr);
if (addr2)
addr = addr2;
}
- store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
static struct xstormy16_frame_cache *
static struct xstormy16_frame_cache *
xstormy16_frame_cache (struct frame_info *this_frame, void **this_cache)
{
+ struct gdbarch *gdbarch = get_frame_arch (this_frame);
struct xstormy16_frame_cache *cache;
CORE_ADDR current_pc;
int i;
cache->pc = get_frame_func (this_frame);
current_pc = get_frame_pc (this_frame);
if (cache->pc)
- xstormy16_analyze_prologue (cache->pc, current_pc, cache, this_frame);
+ xstormy16_analyze_prologue (gdbarch, cache->pc, current_pc,
+ cache, this_frame);
if (!cache->uses_fp)
cache->base = get_frame_register_unsigned (this_frame, E_SP_REGNUM);
static int
extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int winsize = 4;
int insn;
gdb_byte buf[4];
/* Read the previous instruction (should be a call[x]{4|8|12}. */
read_memory (pc-3, buf, 3);
- insn = extract_unsigned_integer (buf, 3);
+ insn = extract_unsigned_integer (buf, 3, byte_order);
/* Decode call instruction:
Little Endian
call{0,4,8,12} 0101 || {00,01,10,11} || OFFSET
callx{0,4,8,12} 0000 || {00,01,10,11} || 11 || OFFSET. */
- if (gdbarch_byte_order (gdbarch) == BFD_ENDIAN_LITTLE)
+ if (byte_order == BFD_ENDIAN_LITTLE)
{
if (((insn & 0xf) == 0x5) || ((insn & 0xcf) == 0xc0))
winsize = (insn & 0x30) >> 2; /* 0, 4, 8, 12. */
int regnum,
gdb_byte *buffer)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
DEBUGTRACE ("xtensa_pseudo_register_read (... regnum = %d (%s) ...)\n",
regnum, xtensa_register_name (gdbarch, regnum));
regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
regnum = arreg_number (gdbarch, regnum,
- extract_unsigned_integer (buf, 4));
+ extract_unsigned_integer (buf, 4, byte_order));
}
/* We can always read non-pseudo registers. */
int regnum,
const gdb_byte *buffer)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
+
DEBUGTRACE ("xtensa_pseudo_register_write (... regnum = %d (%s) ...)\n",
regnum, xtensa_register_name (gdbarch, regnum));
regcache_raw_read (regcache,
gdbarch_tdep (gdbarch)->wb_regnum, buf);
regnum = arreg_number (gdbarch, regnum,
- extract_unsigned_integer (buf, 4));
+ extract_unsigned_integer (buf, 4, byte_order));
}
/* We can always write 'core' registers.
xtensa_frame_cache_t *cache;
CORE_ADDR ra, wb, ws, pc, sp, ps;
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int fp_regnum;
char op1;
int windowed;
ws = get_frame_register_unsigned (this_frame,
gdbarch_tdep (gdbarch)->ws_regnum);
- op1 = read_memory_integer (pc, 1);
+ op1 = read_memory_integer (pc, 1, byte_order);
if (XTENSA_IS_ENTRY (gdbarch, op1))
{
int callinc = CALLINC (ps);
/* Set A4...A7/A11. */
/* Get the SP of the frame previous to the previous one.
To achieve this, we have to dereference SP twice. */
- sp = (CORE_ADDR) read_memory_integer (sp - 12, 4);
- sp = (CORE_ADDR) read_memory_integer (sp - 12, 4);
+ sp = (CORE_ADDR) read_memory_integer (sp - 12, 4, byte_order);
+ sp = (CORE_ADDR) read_memory_integer (sp - 12, 4, byte_order);
sp -= cache->wd.callsize * 4;
for ( i = 4; i < cache->wd.callsize; i++, sp += 4)
We can read caller's SP from the proper spill loction. */
sp = get_frame_register_unsigned
(this_frame, gdbarch_tdep (gdbarch)->a0_base + 1);
- cache->prev_sp = read_memory_integer (sp - 12, 4);
+ cache->prev_sp = read_memory_integer (sp - 12, 4, byte_order);
}
else
{
int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
int size, onstack_size;
gdb_byte *buf = (gdb_byte *) alloca (16);
if (struct_return)
{
- store_unsigned_integer (buf, REGISTER_SIZE, struct_addr);
+ store_unsigned_integer (buf, REGISTER_SIZE, byte_order, struct_addr);
regcache_cooked_write (regcache, ARG_1ST (gdbarch), buf);
}
than REGISTER_SIZE; for larger odd-sized structures the excess
will be left-aligned in the register on both endiannesses. */
- if (n < REGISTER_SIZE
- && gdbarch_byte_order (gdbarch) == BFD_ENDIAN_BIG)
+ if (n < REGISTER_SIZE && byte_order == BFD_ENDIAN_BIG)
{
- ULONGEST v = extract_unsigned_integer (cp, REGISTER_SIZE);
+ ULONGEST v;
+ v = extract_unsigned_integer (cp, REGISTER_SIZE, byte_order);
v = v >> ((REGISTER_SIZE - n) * TARGET_CHAR_BIT);
- store_unsigned_integer (buf, REGISTER_SIZE, v);
+ store_unsigned_integer (buf, REGISTER_SIZE, byte_order, v);
regcache_cooked_write (regcache, r, buf);
cp += REGISTER_SIZE;
{
ra = (bp_addr & 0x3fffffff) | 0x40000000;
regcache_raw_read (regcache, gdbarch_ps_regnum (gdbarch), buf);
- ps = extract_unsigned_integer (buf, 4) & ~0x00030000;
+ ps = extract_unsigned_integer (buf, 4, byte_order) & ~0x00030000;
regcache_cooked_write_unsigned
(regcache, gdbarch_tdep (gdbarch)->a0_base + 4, ra);
regcache_cooked_write_unsigned (regcache,
is only one register window corresponding to WINDOWEBASE. */
regcache_raw_read (regcache, gdbarch_tdep (gdbarch)->wb_regnum, buf);
- regcache_cooked_write_unsigned (regcache,
- gdbarch_tdep (gdbarch)->ws_regnum,
- 1 << extract_unsigned_integer (buf, 4));
+ regcache_cooked_write_unsigned
+ (regcache, gdbarch_tdep (gdbarch)->ws_regnum,
+ 1 << extract_unsigned_integer (buf, 4, byte_order));
}
else
{
the stack frame. */
static void
-call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
+call0_track_op (struct gdbarch *gdbarch,
+ xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
xtensa_insn_kind opclass, int nods, unsigned odv[],
CORE_ADDR pc, CORE_ADDR litbase, int spreg)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned litaddr, litval;
switch (opclass)
litaddr = litbase & 1
? (litbase & ~1) + (signed)odv[1]
: (pc + 3 + (signed)odv[1]) & ~3;
- litval = read_memory_integer(litaddr, 4);
+ litval = read_memory_integer (litaddr, 4, byte_order);
dst[odv[0]].fr_reg = C0_CONST;
dst[odv[0]].fr_ofs = litval;
break;
because they begin with default assumptions that analysis may change. */
static CORE_ADDR
-call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
+call0_analyze_prologue (struct gdbarch *gdbarch,
+ CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
int nregs, xtensa_c0reg_t rt[], int *call0)
{
CORE_ADDR ia; /* Current insn address in prologue. */
}
/* Track register movement and modification for this operation. */
- call0_track_op (rt, rtmp, opclass, nods, odv, ia, litbase, 1);
+ call0_track_op (gdbarch, rt, rtmp, opclass,
+ nods, odv, ia, litbase, 1);
}
}
done:
xtensa_frame_cache_t *cache, CORE_ADDR pc, CORE_ADDR litbase)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
CORE_ADDR start_pc; /* The beginning of the function. */
CORE_ADDR body_pc=UINT_MAX; /* PC, where prologue analysis stopped. */
CORE_ADDR sp, fp, ra;
if (find_pc_partial_function (pc, NULL, &start_pc, NULL))
{
- body_pc = call0_analyze_prologue (start_pc, pc, litbase, C0_NREGS,
+ body_pc = call0_analyze_prologue (gdbarch, start_pc, pc, litbase,
+ C0_NREGS,
&cache->c0.c0_rt[0],
&cache->call0);
}
to_stk = cache->c0.c0_rt[C0_RA].to_stk;
if (to_stk != C0_NOSTK)
ra = (CORE_ADDR)
- read_memory_integer (sp + c0_frmsz + cache->c0.c0_rt[C0_RA].to_stk, 4);
+ read_memory_integer (sp + c0_frmsz + cache->c0.c0_rt[C0_RA].to_stk,
+ 4, byte_order);
else if (cache->c0.c0_rt[C0_RA].fr_reg == C0_CONST
&& cache->c0.c0_rt[C0_RA].fr_ofs == 0)
}
/* No debug line info. Analyze prologue for Call0 or simply skip ENTRY. */
- body_pc = call0_analyze_prologue(start_pc, 0, 0, 0, NULL, NULL);
+ body_pc = call0_analyze_prologue (gdbarch, start_pc, 0, 0, 0, NULL, NULL);
return body_pc != 0 ? body_pc : start_pc;
}