summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog626
-rw-r--r--gdb/ada-lang.c3
-rw-r--r--gdb/ada-valprint.c21
-rw-r--r--gdb/alpha-linux-tdep.c20
-rw-r--r--gdb/alpha-osf1-tdep.c7
-rw-r--r--gdb/alpha-tdep.c58
-rw-r--r--gdb/alpha-tdep.h6
-rw-r--r--gdb/alphafbsd-tdep.c5
-rw-r--r--gdb/alphanbsd-tdep.c7
-rw-r--r--gdb/alphaobsd-tdep.c14
-rw-r--r--gdb/amd64-linux-tdep.c4
-rw-r--r--gdb/amd64-tdep.c42
-rw-r--r--gdb/amd64obsd-tdep.c20
-rw-r--r--gdb/arch-utils.c3
-rw-r--r--gdb/arch-utils.h3
-rw-r--r--gdb/arm-linux-tdep.c16
-rw-r--r--gdb/arm-tdep.c83
-rw-r--r--gdb/arm-wince-tdep.c11
-rw-r--r--gdb/auxv.c5
-rw-r--r--gdb/avr-tdep.c55
-rw-r--r--gdb/bsd-uthread.c15
-rw-r--r--gdb/c-exp.y9
-rw-r--r--gdb/c-lang.c67
-rw-r--r--gdb/c-valprint.c3
-rw-r--r--gdb/charset.c4
-rw-r--r--gdb/charset.h2
-rw-r--r--gdb/corefile.c26
-rw-r--r--gdb/cp-valprint.c6
-rw-r--r--gdb/cris-tdep.c79
-rw-r--r--gdb/defs.h15
-rw-r--r--gdb/dfp.c65
-rw-r--r--gdb/dfp.h28
-rw-r--r--gdb/dwarf2-frame.c7
-rw-r--r--gdb/dwarf2expr.c25
-rw-r--r--gdb/dwarf2loc.c3
-rw-r--r--gdb/dwarf2read.c4
-rw-r--r--gdb/f-valprint.c5
-rw-r--r--gdb/findvar.c40
-rw-r--r--gdb/frame-unwind.c3
-rw-r--r--gdb/frame.c20
-rw-r--r--gdb/frv-linux-tdep.c26
-rw-r--r--gdb/frv-tdep.c42
-rw-r--r--gdb/gdbarch.c4
-rw-r--r--gdb/gdbarch.h2
-rwxr-xr-xgdb/gdbarch.sh2
-rw-r--r--gdb/gdbcore.h13
-rw-r--r--gdb/gnu-v3-abi.c16
-rw-r--r--gdb/h8300-tdep.c99
-rw-r--r--gdb/hppa-hpux-nat.c12
-rw-r--r--gdb/hppa-hpux-tdep.c96
-rw-r--r--gdb/hppa-linux-tdep.c26
-rw-r--r--gdb/hppa-tdep.c85
-rw-r--r--gdb/hppa-tdep.h6
-rw-r--r--gdb/hppabsd-tdep.c8
-rw-r--r--gdb/hpux-thread.c3
-rw-r--r--gdb/i386-cygwin-tdep.c7
-rw-r--r--gdb/i386-darwin-nat.c11
-rw-r--r--gdb/i386-darwin-tdep.c14
-rw-r--r--gdb/i386-linux-nat.c8
-rw-r--r--gdb/i386-linux-tdep.c6
-rw-r--r--gdb/i386-nto-tdep.c4
-rw-r--r--gdb/i386-tdep.c118
-rw-r--r--gdb/i386-tdep.h3
-rw-r--r--gdb/i386bsd-tdep.c6
-rw-r--r--gdb/i386nbsd-tdep.c5
-rw-r--r--gdb/i386obsd-nat.c6
-rw-r--r--gdb/i386obsd-tdep.c20
-rw-r--r--gdb/i387-tdep.c6
-rw-r--r--gdb/ia64-linux-tdep.c6
-rw-r--r--gdb/ia64-tdep.c225
-rw-r--r--gdb/ia64-tdep.h2
-rw-r--r--gdb/iq2000-tdep.c26
-rw-r--r--gdb/irix5-nat.c11
-rw-r--r--gdb/jv-lang.c3
-rw-r--r--gdb/jv-valprint.c9
-rw-r--r--gdb/lm32-tdep.c26
-rw-r--r--gdb/m32c-tdep.c30
-rw-r--r--gdb/m32r-tdep.c48
-rw-r--r--gdb/m68hc11-tdep.c26
-rw-r--r--gdb/m68k-tdep.c59
-rw-r--r--gdb/m68klinux-tdep.c20
-rw-r--r--gdb/m88k-tdep.c17
-rw-r--r--gdb/mep-tdep.c26
-rw-r--r--gdb/mi/mi-main.c4
-rw-r--r--gdb/mips-linux-tdep.c41
-rw-r--r--gdb/mips-tdep.c152
-rw-r--r--gdb/mipsnbsd-tdep.c5
-rw-r--r--gdb/mn10300-tdep.c50
-rw-r--r--gdb/monitor.c11
-rw-r--r--gdb/moxie-tdep.c21
-rw-r--r--gdb/mt-tdep.c42
-rw-r--r--gdb/objc-lang.c95
-rw-r--r--gdb/p-lang.c11
-rw-r--r--gdb/p-valprint.c17
-rw-r--r--gdb/ppc-linux-nat.c5
-rw-r--r--gdb/ppc-linux-tdep.c26
-rw-r--r--gdb/ppc-sysv-tdep.c22
-rw-r--r--gdb/ppcobsd-tdep.c10
-rw-r--r--gdb/printcmd.c16
-rw-r--r--gdb/procfs.c5
-rw-r--r--gdb/python/python-value.c3
-rw-r--r--gdb/regcache.c32
-rw-r--r--gdb/remote-m32r-sdi.c4
-rw-r--r--gdb/remote-mips.c48
-rw-r--r--gdb/rs6000-aix-tdep.c20
-rw-r--r--gdb/rs6000-tdep.c92
-rw-r--r--gdb/s390-tdep.c57
-rw-r--r--gdb/scm-exp.c3
-rw-r--r--gdb/scm-lang.c10
-rw-r--r--gdb/scm-lang.h6
-rw-r--r--gdb/scm-valprint.c15
-rw-r--r--gdb/score-tdep.c14
-rw-r--r--gdb/sh-tdep.c72
-rw-r--r--gdb/sh64-tdep.c69
-rw-r--r--gdb/solib-darwin.c5
-rw-r--r--gdb/solib-frv.c48
-rw-r--r--gdb/solib-irix.c70
-rw-r--r--gdb/solib-som.c28
-rw-r--r--gdb/solib-sunos.c12
-rw-r--r--gdb/solib-svr4.c35
-rw-r--r--gdb/sparc-linux-tdep.c5
-rw-r--r--gdb/sparc-tdep.c55
-rw-r--r--gdb/sparc-tdep.h2
-rw-r--r--gdb/sparc64-linux-tdep.c6
-rw-r--r--gdb/sparc64-tdep.c27
-rw-r--r--gdb/sparc64nbsd-tdep.c3
-rw-r--r--gdb/sparc64obsd-tdep.c20
-rw-r--r--gdb/sparcnbsd-tdep.c3
-rw-r--r--gdb/sparcobsd-tdep.c20
-rw-r--r--gdb/spu-linux-nat.c7
-rw-r--r--gdb/spu-tdep.c153
-rw-r--r--gdb/stack.c11
-rw-r--r--gdb/symfile.c37
-rw-r--r--gdb/target.c7
-rw-r--r--gdb/target.h3
-rw-r--r--gdb/tramp-frame.c4
-rw-r--r--gdb/v850-tdep.c31
-rw-r--r--gdb/valarith.c45
-rw-r--r--gdb/valops.c15
-rw-r--r--gdb/valprint.c19
-rw-r--r--gdb/valprint.h3
-rw-r--r--gdb/value.c22
-rw-r--r--gdb/vax-tdep.c34
-rw-r--r--gdb/xstormy16-tdep.c61
-rw-r--r--gdb/xtensa-tdep.c62
145 files changed, 2989 insertions, 1465 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index bf964d81621..061ab4d69b2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,631 @@
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.
(paddress): Add GDBARCH parameter.
* utils.c (strlen_paddr, paddr, paddr_nz): Remove.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 2eac7052bc9..9b5d2c616ff 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -7922,7 +7922,8 @@ ada_value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
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;
}
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index adc81860820..565172c2ed4 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -292,12 +292,13 @@ ada_emit_char (int c, struct type *type, struct ui_file *stream,
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 */
@@ -466,6 +467,7 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
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;
@@ -496,8 +498,8 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
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;
@@ -514,8 +516,8 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
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;
@@ -532,8 +534,8 @@ printstr (struct ui_file *stream, struct type *elttype, const gdb_byte *string,
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;
}
}
@@ -610,6 +612,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
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;
@@ -641,7 +644,7 @@ ada_val_print_array (struct type *type, const gdb_byte *valaddr,
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;
}
diff --git a/gdb/alpha-linux-tdep.c b/gdb/alpha-linux-tdep.c
index 25b6b2d0fa3..02e4d037dda 100644
--- a/gdb/alpha-linux-tdep.c
+++ b/gdb/alpha-linux-tdep.c
@@ -44,9 +44,9 @@
*/
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 */
@@ -66,7 +66,7 @@ alpha_linux_sigtramp_offset_1 (CORE_ADDR pc)
}
static LONGEST
-alpha_linux_sigtramp_offset (CORE_ADDR pc)
+alpha_linux_sigtramp_offset (struct gdbarch *gdbarch, CORE_ADDR pc)
{
long i, off;
@@ -74,7 +74,7 @@ alpha_linux_sigtramp_offset (CORE_ADDR pc)
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;
@@ -84,7 +84,7 @@ alpha_linux_sigtramp_offset (CORE_ADDR pc)
{
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;
}
@@ -92,14 +92,16 @@ alpha_linux_sigtramp_offset (CORE_ADDR pc)
}
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;
@@ -107,7 +109,7 @@ alpha_linux_sigcontext_addr (struct frame_info *this_frame)
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:
@@ -119,7 +121,7 @@ alpha_linux_sigcontext_addr (struct frame_info *this_frame)
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. */
diff --git a/gdb/alpha-osf1-tdep.c b/gdb/alpha-osf1-tdep.c
index 5fde0e600df..526dd46f087 100644
--- a/gdb/alpha-osf1-tdep.c
+++ b/gdb/alpha-osf1-tdep.c
@@ -27,7 +27,8 @@
#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);
}
@@ -35,13 +36,15 @@ alpha_osf1_pc_in_sigtramp (CORE_ADDR pc, char *func_name)
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
diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c
index 28ce8b17e56..1a188cf3094 100644
--- a/gdb/alpha-tdep.c
+++ b/gdb/alpha-tdep.c
@@ -154,9 +154,10 @@ alpha_register_reggroup_p (struct gdbarch *gdbarch, int regnum,
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;
@@ -176,20 +177,21 @@ alpha_lds (void *out, const void *in)
}
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
@@ -215,7 +217,7 @@ alpha_register_to_value (struct frame_info *frame, int regnum,
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"));
@@ -231,7 +233,7 @@ alpha_value_to_register (struct frame_info *frame, int regnum,
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"));
@@ -258,6 +260,7 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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
@@ -408,7 +411,8 @@ alpha_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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++)
@@ -432,6 +436,8 @@ static void
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;
@@ -443,7 +449,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
{
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:
@@ -486,7 +492,7 @@ alpha_extract_return_value (struct type *valtype, struct regcache *regcache,
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;
}
}
@@ -509,7 +515,7 @@ alpha_store_return_value (struct type *valtype, struct regcache *regcache,
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;
@@ -634,15 +640,16 @@ alpha_after_prologue (CORE_ADDR pc)
/* 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
@@ -686,7 +693,7 @@ alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -721,7 +728,9 @@ alpha_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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];
@@ -731,7 +740,7 @@ alpha_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
@@ -810,7 +819,7 @@ alpha_sigtramp_frame_this_id (struct frame_info *this_frame,
{
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
@@ -876,7 +885,7 @@ alpha_sigtramp_frame_sniffer (const struct frame_unwind *self,
/* 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;
@@ -931,7 +940,7 @@ alpha_heuristic_proc_start (struct gdbarch *gdbarch, CORE_ADDR pc)
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 */
@@ -1027,7 +1036,7 @@ alpha_heuristic_frame_unwind_cache (struct frame_info *this_frame,
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) */
{
@@ -1115,7 +1124,7 @@ alpha_heuristic_frame_unwind_cache (struct frame_info *this_frame,
{
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) */
{
@@ -1358,13 +1367,14 @@ fp_register_sign_bit (LONGEST reg)
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;
@@ -1401,7 +1411,7 @@ alpha_next_pc (struct frame_info *frame, CORE_ADDR pc)
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);
diff --git a/gdb/alpha-tdep.h b/gdb/alpha-tdep.h
index cf48077d82d..2c2b1006125 100644
--- a/gdb/alpha-tdep.h
+++ b/gdb/alpha-tdep.h
@@ -76,7 +76,7 @@ struct gdbarch_tdep
/* 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. */
@@ -86,7 +86,7 @@ struct gdbarch_tdep
/* 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);
@@ -102,7 +102,7 @@ struct gdbarch_tdep
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);
diff --git a/gdb/alphafbsd-tdep.c b/gdb/alphafbsd-tdep.c
index d55f7a6fa2c..044631eaec4 100644
--- a/gdb/alphafbsd-tdep.c
+++ b/gdb/alphafbsd-tdep.c
@@ -65,13 +65,14 @@ CORE_ADDR alphafbsd_sigtramp_start = 0x11ffff68;
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;
}
diff --git a/gdb/alphanbsd-tdep.c b/gdb/alphanbsd-tdep.c
index 2d04b73657d..11179c25c4f 100644
--- a/gdb/alphanbsd-tdep.c
+++ b/gdb/alphanbsd-tdep.c
@@ -211,7 +211,7 @@ static const unsigned char sigtramp_retcode[] =
#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;
@@ -241,10 +241,11 @@ alphanbsd_sigtramp_offset (CORE_ADDR pc)
}
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
diff --git a/gdb/alphaobsd-tdep.c b/gdb/alphaobsd-tdep.c
index 72b06954466..895eb5b763c 100644
--- a/gdb/alphaobsd-tdep.c
+++ b/gdb/alphaobsd-tdep.c
@@ -40,13 +40,14 @@
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;
@@ -55,12 +56,12 @@ alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
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;
@@ -70,14 +71,15 @@ alphaobsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
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;
diff --git a/gdb/amd64-linux-tdep.c b/gdb/amd64-linux-tdep.c
index bdc93f5ebd3..92f52655d57 100644
--- a/gdb/amd64-linux-tdep.c
+++ b/gdb/amd64-linux-tdep.c
@@ -153,11 +153,13 @@ amd64_linux_sigtramp_p (struct frame_info *this_frame)
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
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index d39c5e02358..258496a4a59 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -677,6 +677,7 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -685,17 +686,17 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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. */
@@ -1034,6 +1035,7 @@ static void
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;
@@ -1047,7 +1049,7 @@ fixup_riprel (struct gdbarch *gdbarch, struct displaced_step_closure *dsc,
++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;
@@ -1251,6 +1253,7 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch,
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;
@@ -1354,9 +1357,9 @@ amd64_displaced_step_fixup (struct gdbarch *gdbarch,
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,
@@ -1589,9 +1592,11 @@ amd64_analyze_stack_align (CORE_ADDR pc, CORE_ADDR current_pc,
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;
@@ -1601,7 +1606,7 @@ amd64_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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 */
{
@@ -1636,7 +1641,8 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
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;
@@ -1649,6 +1655,8 @@ amd64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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;
@@ -1661,13 +1669,14 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
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)
@@ -1691,13 +1700,14 @@ amd64_frame_cache (struct frame_info *this_frame, void **this_cache)
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
@@ -1773,8 +1783,10 @@ static const struct frame_unwind amd64_frame_unwind =
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;
@@ -1785,7 +1797,7 @@ amd64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
diff --git a/gdb/amd64obsd-tdep.c b/gdb/amd64obsd-tdep.c
index be5641db620..1938bdd7279 100644
--- a/gdb/amd64obsd-tdep.c
+++ b/gdb/amd64obsd-tdep.c
@@ -251,6 +251,8 @@ static void
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];
@@ -263,12 +265,12 @@ amd64obsd_supply_uthread (struct regcache *regcache,
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);
}
@@ -280,7 +282,7 @@ amd64obsd_supply_uthread (struct regcache *regcache,
/* 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);
@@ -293,6 +295,8 @@ static void
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];
@@ -308,10 +312,10 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
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. */
@@ -326,7 +330,7 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
/* 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);
@@ -343,6 +347,8 @@ amd64obsd_collect_uthread (const struct regcache *regcache,
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;
@@ -370,7 +376,7 @@ amd64obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
/* 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. */
diff --git a/gdb/arch-utils.c b/gdb/arch-utils.c
index 996f149cf23..9e5e855fcc7 100644
--- a/gdb/arch-utils.c
+++ b/gdb/arch-utils.c
@@ -118,7 +118,8 @@ generic_skip_solib_resolver (struct gdbarch *gdbarch, CORE_ADDR pc)
}
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;
}
diff --git a/gdb/arch-utils.h b/gdb/arch-utils.h
index 555ff59a645..9d95d3f2634 100644
--- a/gdb/arch-utils.h
+++ b/gdb/arch-utils.h
@@ -92,7 +92,8 @@ extern CORE_ADDR generic_skip_trampoline_code (struct frame_info *frame,
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);
diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c
index dc72ee14f55..20419cbb249 100644
--- a/gdb/arm-linux-tdep.c
+++ b/gdb/arm-linux-tdep.c
@@ -284,8 +284,10 @@ arm_linux_sigreturn_init (const struct tramp_frame *self,
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,
@@ -302,8 +304,10 @@ arm_linux_rt_sigreturn_init (const struct tramp_frame *self,
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,
@@ -368,6 +372,8 @@ arm_linux_supply_gregset (const struct regset *regset,
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;
@@ -392,9 +398,9 @@ arm_linux_supply_gregset (const struct regset *regset,
{
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);
}
}
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index bba869e01cd..58bdc1f0375 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -68,19 +68,6 @@ static int arm_debug;
#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;
@@ -387,6 +374,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -402,10 +390,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
{
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 } */
{
@@ -533,6 +518,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -571,10 +557,7 @@ arm_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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 */
@@ -754,6 +737,8 @@ arm_scan_prologue (struct frame_info *this_frame,
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);
@@ -827,7 +812,7 @@ arm_scan_prologue (struct frame_info *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
{
@@ -870,10 +855,8 @@ arm_scan_prologue (struct frame_info *this_frame,
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 */
{
@@ -1400,6 +1383,7 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1481,11 +1465,12 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
&& 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));
}
}
@@ -1500,8 +1485,9 @@ arm_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
/* 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",
@@ -1843,13 +1829,14 @@ static CORE_ADDR
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} */
{
@@ -1859,7 +1846,7 @@ thumb_get_next_pc (struct frame_info *frame, CORE_ADDR 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"));
@@ -1877,9 +1864,8 @@ thumb_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
}
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. */
@@ -1905,6 +1891,8 @@ CORE_ADDR
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;
@@ -1914,10 +1902,7 @@ arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
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 */
@@ -2098,7 +2083,7 @@ arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
base -= offset;
}
nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base,
- 4);
+ 4, byte_order);
nextpc = gdbarch_addr_bits_remove (gdbarch, nextpc);
@@ -2136,7 +2121,7 @@ arm_get_next_pc (struct frame_info *frame, CORE_ADDR pc)
nextpc =
(CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val
+ offset),
- 4);
+ 4, byte_order);
}
nextpc = gdbarch_addr_bits_remove
(gdbarch, nextpc);
@@ -2309,6 +2294,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
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))
{
@@ -2363,7 +2349,7 @@ arm_extract_return_value (struct type *type, struct regcache *regs,
store_unsigned_integer (valbuf,
(len > INT_REGISTER_SIZE
? INT_REGISTER_SIZE : len),
- tmp);
+ byte_order, tmp);
len -= INT_REGISTER_SIZE;
valbuf += INT_REGISTER_SIZE;
}
@@ -2498,6 +2484,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
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)
{
@@ -2541,7 +2528,7 @@ arm_store_return_value (struct type *type, struct regcache *regs,
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
@@ -2612,9 +2599,11 @@ arm_return_value (struct gdbarch *gdbarch, struct type *func_type,
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);
@@ -2622,7 +2611,7 @@ arm_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
diff --git a/gdb/arm-wince-tdep.c b/gdb/arm-wince-tdep.c
index ad34fb25c71..46d877055aa 100644
--- a/gdb/arm-wince-tdep.c
+++ b/gdb/arm-wince-tdep.c
@@ -24,6 +24,7 @@
#include "target.h"
#include "solib.h"
#include "solib-target.h"
+#include "frame.h"
#include "gdb_string.h"
@@ -39,6 +40,8 @@ static const char arm_wince_thumb_le_breakpoint[] = { 0xfe, 0xdf };
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;
@@ -50,11 +53,11 @@ arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
.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;
@@ -66,7 +69,7 @@ arm_pe_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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;
diff --git a/gdb/auxv.c b/gdb/auxv.c
index 6b98fed5188..7b4ecbe2bc8 100644
--- a/gdb/auxv.c
+++ b/gdb/auxv.c
@@ -82,6 +82,7 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
{
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)
@@ -90,9 +91,9 @@ default_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
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;
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 4e7c78a6be4..7f56e540099 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -72,9 +72,6 @@
#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
@@ -282,17 +279,19 @@ static void
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));
}
}
@@ -301,7 +300,9 @@ static CORE_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
@@ -423,9 +424,10 @@ avr_write_pc (struct regcache *regcache, CORE_ADDR val)
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;
@@ -458,12 +460,12 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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)
{
@@ -494,28 +496,28 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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;
@@ -526,7 +528,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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)
{
@@ -546,7 +548,8 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
{
/* 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;
@@ -630,7 +633,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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. */
@@ -699,14 +702,14 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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);
}
@@ -744,7 +747,7 @@ avr_scan_prologue (CORE_ADDR pc_beg, CORE_ADDR pc_end,
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 */
@@ -776,7 +779,7 @@ avr_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -817,13 +820,15 @@ static void
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
{
@@ -909,7 +914,8 @@ avr_frame_unwind_cache (struct frame_info *this_frame,
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))
@@ -1015,6 +1021,8 @@ static struct value *
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);
@@ -1171,6 +1179,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
@@ -1209,7 +1218,7 @@ avr_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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--,
diff --git a/gdb/bsd-uthread.c b/gdb/bsd-uthread.c
index 22962c06ed6..1de2da4f1d7 100644
--- a/gdb/bsd-uthread.c
+++ b/gdb/bsd-uthread.c
@@ -93,7 +93,8 @@ bsd_uthread_set_collect_uthread (struct gdbarch *gdbarch,
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"));
@@ -136,13 +137,14 @@ bsd_uthread_lookup_address (const char *name, struct objfile *objfile)
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
@@ -347,6 +349,7 @@ static ptid_t
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);
@@ -372,7 +375,7 @@ bsd_uthread_wait (struct target_ops *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);
}
@@ -404,6 +407,7 @@ bsd_uthread_resume (struct target_ops *ops,
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);
@@ -414,7 +418,7 @@ bsd_uthread_thread_alive (struct target_ops *ops, ptid_t 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;
}
@@ -480,6 +484,7 @@ static char *bsd_uthread_state[] =
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)
@@ -487,7 +492,7 @@ bsd_uthread_extra_thread_info (struct thread_info *info)
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];
}
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 75851d0c509..d0a6332911c 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -1181,7 +1181,8 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
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;
}
@@ -1191,7 +1192,8 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
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;
}
@@ -1201,7 +1203,8 @@ parse_number (char *p, int len, int parsed_float, YYSTYPE *putithere)
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;
}
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 57181433a5a..55dc042dfee 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -42,23 +42,24 @@ extern void _initialize_c_language (void);
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";
@@ -69,10 +70,11 @@ charset_for_string_type (enum c_string_type str_type)
/* 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;
@@ -131,7 +133,9 @@ classify_type (struct type *elttype, const char **encoding)
result = C_CHAR;
done:
- *encoding = charset_for_string_type (result);
+ if (encoding)
+ *encoding = charset_for_string_type (result, byte_order);
+
return result;
}
@@ -172,8 +176,8 @@ append_string_as_wide (const char *string, struct obstack *output)
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;
@@ -219,7 +223,8 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
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);
}
@@ -246,6 +251,7 @@ print_wchar (gdb_wint_t w, const gdb_byte *orig, int orig_len,
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;
@@ -253,7 +259,7 @@ c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
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);
@@ -299,14 +305,14 @@ c_emit_char (int c, struct type *type, struct ui_file *stream, int quoter)
{
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. */
@@ -328,9 +334,8 @@ void
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:
@@ -362,6 +367,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
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;
@@ -380,10 +386,11 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
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:
@@ -411,7 +418,8 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *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;
}
@@ -481,7 +489,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
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. */
@@ -514,7 +522,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
while (reps-- > 0)
{
print_wchar (current_char, orig_buf, orig_len, width,
- &wchar_buf, '"', &need_escape);
+ byte_order, &wchar_buf, '"', &need_escape);
++things_printed;
}
}
@@ -541,7 +549,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
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;
@@ -555,7 +563,7 @@ c_printstr (struct ui_file *stream, struct type *type, const gdb_byte *string,
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;
@@ -612,6 +620,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
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;
@@ -659,7 +668,8 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
/* 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. */
@@ -671,7 +681,7 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
else
{
err = read_string (value_as_address (value), -1, width, fetchlimit,
- buffer, length);
+ byte_order, buffer, length);
if (err)
{
xfree (*buffer);
@@ -682,7 +692,8 @@ c_get_string (struct value *value, gdb_byte **buffer, int *length,
/* 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 ();
@@ -905,6 +916,7 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
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);
@@ -941,7 +953,8 @@ evaluate_subexp_c (struct type *expect_type, struct expression *exp,
/* 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)
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 64b30c2fc37..dc391ee2244 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -153,6 +153,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
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;
@@ -190,7 +191,7 @@ c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
&& 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;
diff --git a/gdb/charset.c b/gdb/charset.c
index 43b69ec372a..a59d9c65d33 100644
--- a/gdb/charset.c
+++ b/gdb/charset.c
@@ -358,9 +358,9 @@ target_charset (void)
}
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;
diff --git a/gdb/charset.h b/gdb/charset.h
index 60abb18d3d8..1b88dae6c94 100644
--- a/gdb/charset.h
+++ b/gdb/charset.h
@@ -34,7 +34,7 @@
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. */
diff --git a/gdb/corefile.c b/gdb/corefile.c
index 3039e8c7f85..6de0772584c 100644
--- a/gdb/corefile.c
+++ b/gdb/corefile.c
@@ -246,6 +246,7 @@ struct captured_read_memory_integer_arguments
{
CORE_ADDR memaddr;
int len;
+ enum bfd_endian byte_order;
LONGEST result;
};
@@ -262,8 +263,9 @@ do_captured_read_memory_integer (void *data)
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;
}
@@ -273,12 +275,14 @@ do_captured_read_memory_integer (void *data)
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);
@@ -289,21 +293,21 @@ safe_read_memory_integer (CORE_ADDR memaddr, int len, LONGEST *return_value)
}
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
@@ -353,19 +357,21 @@ write_memory (CORE_ADDR memaddr, const bfd_byte *myaddr, int len)
/* 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);
}
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index d264b40e25b..49d71a4480a 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -564,13 +564,17 @@ void
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
diff --git a/gdb/cris-tdep.c b/gdb/cris-tdep.c
index 81b1edcd204..999231cfe06 100644
--- a/gdb/cris-tdep.c
+++ b/gdb/cris-tdep.c
@@ -259,13 +259,14 @@ cris_rt_sigtramp_start (struct frame_info *this_frame)
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);
@@ -321,6 +322,7 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *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;
@@ -346,7 +348,7 @@ cris_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
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);
@@ -535,6 +537,7 @@ struct instruction_environment
int delay_slot_pc_active;
int xflag_found;
int disable_interrupt;
+ int byte_order;
} inst_env_type;
/* Machine-dependencies in CRIS for opcodes. */
@@ -862,6 +865,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -952,7 +956,7 @@ cris_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
}
}
@@ -1085,6 +1089,8 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
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;
@@ -1126,12 +1132,12 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
/* 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)
@@ -1195,7 +1201,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
{
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
@@ -1240,7 +1246,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
&& (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))
@@ -1264,7 +1270,7 @@ cris_scan_prologue (CORE_ADDR pc, struct frame_info *this_frame,
&& (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))
@@ -1703,21 +1709,23 @@ static void
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
@@ -1872,6 +1880,8 @@ static void
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);
@@ -1879,15 +1889,15 @@ cris_extract_return_value (struct type *type, struct regcache *regcache,
{
/* 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"));
@@ -2054,6 +2064,7 @@ find_step_target (struct frame_info *frame, inst_env_type *inst_env)
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++)
@@ -2074,13 +2085,14 @@ find_step_target (struct frame_info *frame, inst_env_type *inst_env)
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
@@ -2209,7 +2221,8 @@ process_autoincrement (int size, unsigned short inst, inst_env_type *inst_env)
/* 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. */
@@ -2235,7 +2248,8 @@ bdap_prefix (unsigned short inst, inst_env_type *inst_env)
/* 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)
{
@@ -2301,7 +2315,8 @@ dip_prefix (unsigned short inst, inst_env_type *inst_env)
/* 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)
@@ -2368,7 +2383,7 @@ sixteen_bit_offset_branch_op (unsigned short inst, inst_env_type *inst_env)
}
/* 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. */
@@ -2877,13 +2892,14 @@ none_reg_mode_jump_op (unsigned short inst, inst_env_type *inst_env)
/* 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)
@@ -3058,7 +3074,8 @@ move_mem_to_reg_movem_op (unsigned short inst, inst_env_type *inst_env)
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. */
@@ -3082,7 +3099,7 @@ move_mem_to_reg_movem_op (unsigned short inst, inst_env_type *inst_env)
}
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. */
@@ -3396,7 +3413,7 @@ reg_mode_add_sub_cmp_and_or_move_op (unsigned short inst,
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;
@@ -3410,7 +3427,7 @@ get_data_from_address (unsigned short *inst, CORE_ADDR address)
/* 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)
@@ -3436,7 +3453,8 @@ handle_prefix_assign_mode_for_aritm_op (unsigned short inst,
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. */
@@ -3465,7 +3483,8 @@ three_operand_add_sub_cmp_and_or_op (unsigned short inst,
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. */
@@ -3528,7 +3547,7 @@ handle_inc_and_index_mode_for_aritm_op (unsigned short inst,
/* 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. */
diff --git a/gdb/defs.h b/gdb/defs.h
index 5aa3a72fd93..6dc5a6c28a1 100644
--- a/gdb/defs.h
+++ b/gdb/defs.h
@@ -1043,18 +1043,23 @@ enum { MAX_REGISTER_SIZE = 16 };
/* 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);
diff --git a/gdb/dfp.c b/gdb/dfp.c
index 4b3cdb1f95b..4ee32bb3a68 100644
--- a/gdb/dfp.c
+++ b/gdb/dfp.c
@@ -34,7 +34,8 @@
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;
@@ -44,7 +45,7 @@ match_endianness (const gdb_byte *from, int len, gdb_byte *to)
#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
@@ -141,11 +142,12 @@ decimal_to_number (const gdb_byte *from, int len, decNumber *to)
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)
{
@@ -168,7 +170,8 @@ decimal_to_string (const gdb_byte *decbytes, int len, char *s)
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];
@@ -191,7 +194,7 @@ decimal_from_string (gdb_byte *decbytes, int len, const char *string)
break;
}
- match_endianness (dec, len, decbytes);
+ match_endianness (dec, len, byte_order, decbytes);
/* Check for errors in the DFP operation. */
decimal_check_errors (&set);
@@ -202,7 +205,8 @@ decimal_from_string (gdb_byte *decbytes, int len, const char *string)
/* 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];
@@ -223,7 +227,7 @@ decimal_from_integral (struct value *from, gdb_byte *to, int len)
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
@@ -232,41 +236,46 @@ decimal_from_integral (struct value *from, gdb_byte *to, int len)
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);
@@ -301,17 +310,17 @@ decimal_binop (enum exp_opcode op, const gdb_byte *x, int len_x,
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);
@@ -321,15 +330,16 @@ decimal_is_zero (const gdb_byte *x, int len)
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);
@@ -356,16 +366,17 @@ decimal_compare (const gdb_byte *x, int len_x, const gdb_byte *y, int len_y)
/* 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);
}
diff --git a/gdb/dfp.h b/gdb/dfp.h
index b8df9e89e0d..4ac7e307a25 100644
--- a/gdb/dfp.h
+++ b/gdb/dfp.h
@@ -29,16 +29,22 @@
* (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
diff --git a/gdb/dwarf2-frame.c b/gdb/dwarf2-frame.c
index fb5b08b6cb4..ce13a5d4448 100644
--- a/gdb/dwarf2-frame.c
+++ b/gdb/dwarf2-frame.c
@@ -379,6 +379,7 @@ execute_cfa_program (struct dwarf2_fde *fde, gdb_byte *insn_ptr,
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)
{
@@ -418,17 +419,17 @@ execute_cfa_program (struct dwarf2_fde *fde, gdb_byte *insn_ptr,
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;
diff --git a/gdb/dwarf2expr.c b/gdb/dwarf2expr.c
index fe0fd83c2a2..a9691bdb4a2 100644
--- a/gdb/dwarf2expr.c
+++ b/gdb/dwarf2expr.c
@@ -207,6 +207,7 @@ CORE_ADDR
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)
@@ -227,7 +228,7 @@ dwarf2_read_address (struct gdbarch *gdbarch, gdb_byte *buf,
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,
@@ -277,6 +278,8 @@ static void
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. */
@@ -336,35 +339,35 @@ execute_stack_op (struct dwarf_expr_context *ctx,
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:
@@ -712,13 +715,13 @@ execute_stack_op (struct dwarf_expr_context *ctx,
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;
diff --git a/gdb/dwarf2loc.c b/gdb/dwarf2loc.c
index 027e1358879..7a54f436ab5 100644
--- a/gdb/dwarf2loc.c
+++ b/gdb/dwarf2loc.c
@@ -57,6 +57,7 @@ find_location_expression (struct dwarf2_loclist_baton *baton,
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. */
@@ -89,7 +90,7 @@ find_location_expression (struct dwarf2_loclist_baton *baton,
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)
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 03c78551154..7ed425397b7 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8076,6 +8076,8 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
{
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)
@@ -8091,7 +8093,7 @@ dwarf2_const_value (struct attribute *attr, struct symbol *sym,
/* 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:
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index c6b404493b2..0a574042fcd 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -246,6 +246,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
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;
@@ -409,8 +410,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
}
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)
diff --git a/gdb/findvar.c b/gdb/findvar.c
index 4063bbe1903..8c027c9156a 100644
--- a/gdb/findvar.c
+++ b/gdb/findvar.c
@@ -48,7 +48,8 @@ you lose
#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;
@@ -62,7 +63,7 @@ That operation is not available on integers of more than %d bytes."),
/* 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. */
@@ -82,7 +83,8 @@ That operation is not available on integers of more than %d bytes."),
}
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;
@@ -97,7 +99,7 @@ That operation is not available on integers of more than %d bytes."),
/* 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;
@@ -117,14 +119,14 @@ That operation is not available on integers of more than %d bytes."),
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;
@@ -154,7 +156,8 @@ extract_long_unsigned_integer (const gdb_byte *addr, int orig_len,
if (len <= (int) sizeof (LONGEST))
{
*pval = (LONGEST) extract_unsigned_integer (first_addr,
- sizeof (LONGEST));
+ sizeof (LONGEST),
+ byte_order);
return 1;
}
@@ -178,7 +181,8 @@ extract_typed_address (const gdb_byte *buf, struct type *type)
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;
@@ -186,7 +190,7 @@ store_signed_integer (gdb_byte *addr, int len, LONGEST val)
/* 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)
{
@@ -205,7 +209,8 @@ store_signed_integer (gdb_byte *addr, int len, LONGEST val)
}
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;
@@ -213,7 +218,7 @@ store_unsigned_integer (gdb_byte *addr, int len, ULONGEST val)
/* 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)
{
@@ -312,14 +317,16 @@ CORE_ADDR
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
@@ -328,14 +335,16 @@ void
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);
}
/* Will calling read_var_value or locate_var_value on SYM end
@@ -415,6 +424,7 @@ read_var_value (struct symbol *var, struct frame_info *frame)
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;
diff --git a/gdb/frame-unwind.c b/gdb/frame-unwind.c
index cdfd045d02f..238c6a1b561 100644
--- a/gdb/frame-unwind.c
+++ b/gdb/frame-unwind.c
@@ -165,11 +165,12 @@ frame_unwind_got_constant (struct frame_info *frame, int regnum,
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;
}
diff --git a/gdb/frame.c b/gdb/frame.c
index ebc7ffbffd3..67e06078e97 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -810,10 +810,12 @@ get_frame_register_value (struct frame_info *frame, int regnum)
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
@@ -825,10 +827,12 @@ get_frame_register_signed (struct frame_info *frame, int regnum)
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
@@ -1874,14 +1878,18 @@ LONGEST
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
diff --git a/gdb/frv-linux-tdep.c b/gdb/frv-linux-tdep.c
index d7a7db52d27..f4976270a58 100644
--- a/gdb/frv-linux-tdep.c
+++ b/gdb/frv-linux-tdep.c
@@ -41,8 +41,9 @@ enum {
};
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;
@@ -50,7 +51,7 @@ frv_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
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;
@@ -61,7 +62,7 @@ frv_linux_pc_in_sigtramp (CORE_ADDR pc, char *name)
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;
@@ -168,6 +169,8 @@ static LONGEST
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)
@@ -181,10 +184,10 @@ frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
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)
{
@@ -206,7 +209,7 @@ frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
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
@@ -255,8 +258,10 @@ frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
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;
@@ -273,8 +278,8 @@ frv_linux_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache
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++)
@@ -313,11 +318,12 @@ frv_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
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;
diff --git a/gdb/frv-tdep.c b/gdb/frv-tdep.c
index b187fef8626..cabfa267e77 100644
--- a/gdb/frv-tdep.c
+++ b/gdb/frv-tdep.c
@@ -514,6 +514,8 @@ frv_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
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.
@@ -595,7 +597,7 @@ frv_analyze_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -1007,13 +1009,14 @@ frv_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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.
@@ -1041,7 +1044,7 @@ frv_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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:
@@ -1106,21 +1109,23 @@ static void
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, &regval);
- store_unsigned_integer (valbuf, 4, regval);
+ store_unsigned_integer (valbuf, 4, byte_order, regval);
regcache_cooked_read_unsigned (regcache, 9, &regval);
- 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);
@@ -1136,6 +1141,7 @@ frv_frame_align (struct gdbarch *gdbarch, CORE_ADDR sp)
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;
@@ -1155,9 +1161,9 @@ find_func_descr (struct gdbarch *gdbarch, CORE_ADDR entry_point)
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;
@@ -1167,11 +1173,12 @@ static CORE_ADDR
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;
@@ -1185,6 +1192,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1232,7 +1240,8 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1244,11 +1253,10 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
/* 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;
@@ -1264,7 +1272,7 @@ frv_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
diff --git a/gdb/gdbarch.c b/gdb/gdbarch.c
index c1975f8b435..1cf4f6c776d 100644
--- a/gdb/gdbarch.c
+++ b/gdb/gdbarch.c
@@ -347,7 +347,7 @@ struct gdbarch startup_gdbarch =
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 */
@@ -2682,7 +2682,7 @@ gdbarch_in_solib_return_trampoline (struct gdbarch *gdbarch, CORE_ADDR pc, char
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
diff --git a/gdb/gdbarch.h b/gdb/gdbarch.h
index b3ba92f06a8..4b64af852f6 100644
--- a/gdb/gdbarch.h
+++ b/gdb/gdbarch.h
@@ -563,7 +563,7 @@ extern void set_gdbarch_skip_solib_resolver (struct gdbarch *gdbarch, gdbarch_sk
/* 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);
diff --git a/gdb/gdbarch.sh b/gdb/gdbarch.sh
index 3a1188d3a49..326849a2ec7 100755
--- a/gdb/gdbarch.sh
+++ b/gdb/gdbarch.sh
@@ -563,7 +563,7 @@ f:CORE_ADDR:skip_trampoline_code:struct frame_info *frame, CORE_ADDR pc:frame, p
# 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
diff --git a/gdb/gdbcore.h b/gdb/gdbcore.h
index ec3e1a8a902..e339c0baa5c 100644
--- a/gdb/gdbcore.h
+++ b/gdb/gdbcore.h
@@ -50,13 +50,16 @@ extern void read_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len);
/* 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 */
@@ -77,10 +80,12 @@ extern void write_memory (CORE_ADDR memaddr, const gdb_byte *myaddr, int len);
/* 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);
/* Hook for `exec_file_command' command to call. */
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index b0567676847..0f9d44efc0d 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -514,6 +514,7 @@ gnuv3_decode_method_ptr (struct gdbarch *gdbarch,
{
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;
@@ -525,9 +526,11 @@ gnuv3_decode_method_ptr (struct gdbarch *gdbarch,
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))
{
@@ -632,6 +635,7 @@ gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
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.
@@ -644,13 +648,13 @@ gnuv3_make_method_ptr (struct type *type, gdb_byte *contents,
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);
}
}
diff --git a/gdb/h8300-tdep.c b/gdb/h8300-tdep.c
index f12cb1b73c0..93f0a65895d 100644
--- a/gdb/h8300-tdep.c
+++ b/gdb/h8300-tdep.c
@@ -178,9 +178,10 @@ h8300_init_frame_cache (struct gdbarch *gdbarch,
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 */
@@ -190,14 +191,16 @@ h8300_is_argument_spill (CORE_ADDR pc)
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)
@@ -208,14 +211,15 @@ h8300_is_argument_spill (CORE_ADDR pc)
&& (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)
@@ -224,22 +228,22 @@ h8300_is_argument_spill (CORE_ADDR pc)
}
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)
@@ -287,9 +291,11 @@ h8300_is_argument_spill (CORE_ADDR pc)
*/
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;
@@ -298,7 +304,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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))
{
@@ -312,7 +318,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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;
@@ -322,7 +328,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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;
@@ -335,12 +341,12 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
}
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))
@@ -350,9 +356,9 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
}
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;
@@ -375,7 +381,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
}
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;
@@ -389,7 +395,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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
@@ -413,7 +419,7 @@ h8300_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
/* 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;
@@ -451,7 +457,7 @@ h8300_frame_cache (struct frame_info *this_frame, void **this_cache)
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)
{
@@ -558,7 +564,7 @@ h8300_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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. */
@@ -635,6 +641,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -698,8 +705,9 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
}
}
@@ -718,7 +726,7 @@ h8300_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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);
@@ -736,6 +744,8 @@ static void
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;
@@ -744,20 +754,20 @@ h8300_extract_return_value (struct type *type, struct regcache *regcache,
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
{
@@ -771,6 +781,8 @@ static void
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;
@@ -780,15 +792,16 @@ h8300h_extract_return_value (struct type *type, struct regcache *regcache,
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
{
@@ -835,6 +848,8 @@ static void
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;
@@ -842,11 +857,11 @@ h8300_store_return_value (struct type *type, struct regcache *regcache,
{
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);
@@ -862,6 +877,8 @@ static void
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;
@@ -870,11 +887,11 @@ h8300h_store_return_value (struct type *type, struct regcache *regcache,
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,
diff --git a/gdb/hppa-hpux-nat.c b/gdb/hppa-hpux-nat.c
index a157ca71444..e36a1b10861 100644
--- a/gdb/hppa-hpux-nat.c
+++ b/gdb/hppa-hpux-nat.c
@@ -88,6 +88,7 @@ static void
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;
@@ -135,8 +136,9 @@ hppa_hpux_fetch_register (struct regcache *regcache, int regnum)
`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);
@@ -161,6 +163,7 @@ static void
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;
@@ -181,8 +184,9 @@ hppa_hpux_store_register (struct regcache *regcache, int regnum)
`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;
}
diff --git a/gdb/hppa-hpux-tdep.c b/gdb/hppa-hpux-tdep.c
index 70077f9e288..3bb7b973aaa 100644
--- a/gdb/hppa-hpux-tdep.c
+++ b/gdb/hppa-hpux-tdep.c
@@ -86,8 +86,10 @@ in_opd_section (CORE_ADDR pc)
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;
@@ -133,7 +135,7 @@ hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
{
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. */
@@ -154,8 +156,11 @@ hppa32_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
}
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
@@ -188,7 +193,7 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
/* 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)
@@ -201,17 +206,17 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
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;
@@ -225,8 +230,10 @@ hppa64_hpux_in_solib_call_trampoline (CORE_ADDR pc, char *name)
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
@@ -259,7 +266,7 @@ hppa_hpux_in_solib_return_trampoline (CORE_ADDR pc, char *name)
{
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. */
@@ -301,6 +308,8 @@ static CORE_ADDR
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;
@@ -316,14 +325,12 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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);
@@ -420,7 +427,7 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
}
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. */
@@ -504,7 +511,7 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
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
{
@@ -520,7 +527,7 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
{
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
@@ -533,7 +540,7 @@ hppa_hpux_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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.
@@ -618,6 +625,7 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *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 hppa_hpux_sigtramp_unwind_cache *info;
unsigned int flag;
CORE_ADDR sp, scptr, off;
@@ -642,7 +650,8 @@ hppa_hpux_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
/* 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))
{
@@ -707,6 +716,8 @@ hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind *self,
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);
@@ -723,7 +734,7 @@ hppa_hpux_sigtramp_unwind_sniffer (const struct frame_unwind *self,
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);
}
@@ -746,6 +757,7 @@ static CORE_ADDR
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);
@@ -760,7 +772,7 @@ hppa32_hpux_find_global_pointer (struct gdbarch *gdbarch,
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);
@@ -770,6 +782,7 @@ static CORE_ADDR
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];
@@ -778,7 +791,7 @@ hppa64_hpux_find_global_pointer (struct gdbarch *gdbarch,
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
{
@@ -793,9 +806,11 @@ static unsigned int ldsid_pattern[] = {
};
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;
@@ -806,7 +821,7 @@ hppa_hpux_search_pattern (CORE_ADDR start, CORE_ADDR end,
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++)
{
@@ -829,6 +844,7 @@ static CORE_ADDR
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;
@@ -861,7 +877,8 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
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)
@@ -879,7 +896,8 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
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)
@@ -902,7 +920,7 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -914,7 +932,7 @@ hppa32_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -926,6 +944,7 @@ static CORE_ADDR
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;
@@ -973,7 +992,8 @@ hppa64_hpux_search_dummy_call_sequence (struct gdbarch *gdbarch, CORE_ADDR pc,
{
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;
@@ -1324,18 +1344,20 @@ hppa_hpux_supply_save_state (const struct regset *regset,
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);
}
@@ -1431,6 +1453,8 @@ hppa_hpux_unwind_adjust_stub (struct frame_info *this_frame, CORE_ADDR base,
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;
@@ -1440,19 +1464,19 @@ hppa_hpux_unwind_adjust_stub (struct frame_info *this_frame, CORE_ADDR base,
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);
}
}
diff --git a/gdb/hppa-linux-tdep.c b/gdb/hppa-linux-tdep.c
index 295635addd3..50b8bd3836d 100644
--- a/gdb/hppa-linux-tdep.c
+++ b/gdb/hppa-linux-tdep.c
@@ -87,10 +87,11 @@ static struct insn_pattern hppa_sigtramp[] = {
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;
@@ -99,7 +100,7 @@ insns_match_pattern (CORE_ADDR 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
@@ -130,7 +131,7 @@ insns_match_pattern (CORE_ADDR pc,
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;
@@ -154,7 +155,8 @@ hppa_linux_sigtramp_find_sigcontext (CORE_ADDR pc)
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;
@@ -163,7 +165,7 @@ hppa_linux_sigtramp_find_sigcontext (CORE_ADDR pc)
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
@@ -209,7 +211,7 @@ hppa_linux_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
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:
@@ -299,9 +301,10 @@ hppa_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
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;
@@ -328,6 +331,7 @@ static const struct frame_unwind hppa_linux_sigtramp_frame_unwind = {
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;
@@ -343,7 +347,7 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *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);
}
/* If the address is in the plt section, then the real function hasn't
@@ -379,7 +383,7 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
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)
{
@@ -388,8 +392,8 @@ hppa_linux_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
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;
}
diff --git a/gdb/hppa-tdep.c b/gdb/hppa-tdep.c
index 6d70c6d0680..072e687c815 100644
--- a/gdb/hppa-tdep.c
+++ b/gdb/hppa-tdep.c
@@ -540,6 +540,7 @@ find_unwind_entry (CORE_ADDR pc)
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];
@@ -549,7 +550,7 @@ hppa_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
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. */
@@ -690,6 +691,8 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -737,7 +740,8 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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)
@@ -745,7 +749,7 @@ hppa32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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)));
}
@@ -898,8 +902,9 @@ hppa64_floating_p (const struct type *type)
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);
@@ -930,7 +935,7 @@ hppa64_convert_code_addr_to_fptr (CORE_ADDR 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;
@@ -947,6 +952,7 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1044,8 +1050,9 @@ hppa64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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
@@ -1476,6 +1483,7 @@ static CORE_ADDR
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;
@@ -1557,7 +1565,7 @@ restart:
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)
@@ -1608,7 +1616,7 @@ restart:
{
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);
@@ -1621,7 +1629,7 @@ restart:
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)
@@ -1652,13 +1660,13 @@ restart:
{
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);
@@ -1816,6 +1824,8 @@ static struct hppa_frame_cache *
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;
@@ -1940,7 +1950,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -2109,8 +2119,7 @@ hppa_frame_cache (struct frame_info *this_frame, void **this_cache)
/* 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]",
@@ -2265,6 +2274,8 @@ static const struct frame_unwind hppa_frame_unwind =
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;
@@ -2289,7 +2300,7 @@ hppa_fallback_frame_cache (struct frame_info *this_frame, void **this_cache)
{
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
@@ -2444,7 +2455,7 @@ hppa_stub_unwind_sniffer (const struct frame_unwind *self,
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;
@@ -2690,12 +2701,13 @@ static void
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
@@ -2710,6 +2722,7 @@ hppa_frame_prev_register_helper (struct frame_info *this_frame,
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)
{
@@ -2719,7 +2732,8 @@ hppa_frame_prev_register_helper (struct frame_info *this_frame,
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);
}
@@ -2817,9 +2831,10 @@ static struct insn_pattern hppa_sigtramp[] = {
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;
@@ -2828,7 +2843,7 @@ hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
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
@@ -2843,8 +2858,8 @@ hppa_match_insns (CORE_ADDR pc, struct insn_pattern *pattern,
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;
@@ -2852,7 +2867,8 @@ hppa_match_insns_relaxed (CORE_ADDR pc, struct insn_pattern *pattern,
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;
@@ -2871,7 +2887,8 @@ hppa_in_dyncall (CORE_ADDR pc)
}
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;
@@ -2887,10 +2904,12 @@ hppa_in_solib_call_trampoline (CORE_ADDR pc, char *name)
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
@@ -2917,8 +2936,8 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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]);
@@ -2940,7 +2959,7 @@ hppa_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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));
diff --git a/gdb/hppa-tdep.h b/gdb/hppa-tdep.h
index 4c7b9f7b6f4..2ec9dd43695 100644
--- a/gdb/hppa-tdep.h
+++ b/gdb/hppa-tdep.h
@@ -93,7 +93,8 @@ struct gdbarch_tdep
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
@@ -241,7 +242,8 @@ extern struct minimal_symbol *
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 */
diff --git a/gdb/hppabsd-tdep.c b/gdb/hppabsd-tdep.c
index a1124336549..e690e683e58 100644
--- a/gdb/hppabsd-tdep.c
+++ b/gdb/hppabsd-tdep.c
@@ -32,6 +32,7 @@
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];
@@ -41,7 +42,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
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
@@ -74,7 +75,7 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *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;
@@ -84,7 +85,8 @@ hppabsd_find_global_pointer (struct gdbarch *gdbarch, struct value *function)
/* 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));
diff --git a/gdb/hpux-thread.c b/gdb/hpux-thread.c
index fec7013cd9d..df4c6da9e69 100644
--- a/gdb/hpux-thread.c
+++ b/gdb/hpux-thread.c
@@ -243,6 +243,7 @@ hpux_thread_fetch_registers (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);
cma__t_int_tcb tcb, *tcb_ptr;
struct cleanup *old_chain;
int i;
@@ -291,7 +292,7 @@ hpux_thread_fetch_registers (struct target_ops *ops,
/* 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
diff --git a/gdb/i386-cygwin-tdep.c b/gdb/i386-cygwin-tdep.c
index a0b0ba63879..56fb049c13f 100644
--- a/gdb/i386-cygwin-tdep.c
+++ b/gdb/i386-cygwin-tdep.c
@@ -122,6 +122,7 @@ static void
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;
@@ -147,10 +148,10 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj)
/* 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))
@@ -201,7 +202,7 @@ windows_core_xfer_shared_libraries (struct gdbarch *gdbarch,
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
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 8a90b17a9da..df029bcfa02 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -446,6 +446,7 @@ darwin_check_osabi (darwin_inferior *inf, thread_t thread)
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)];
@@ -459,8 +460,10 @@ i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
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);
@@ -475,6 +478,7 @@ i386_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
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)];
@@ -487,7 +491,8 @@ amd64_darwin_sstep_at_sigreturn (x86_thread_state_t *regs)
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. */
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index fc9198f56d3..fd53e791fa0 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -107,28 +107,32 @@ const int amd64_darwin_thread_state_num_regs =
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];
@@ -136,13 +140,13 @@ amd64_darwin_sigcontext_addr (struct frame_info *this_frame)
/* 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
diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c
index 8ed39304b13..991b27fdd8a 100644
--- a/gdb/i386-linux-nat.c
+++ b/gdb/i386-linux-nat.c
@@ -757,13 +757,15 @@ i386_linux_resume (struct target_ops *ops,
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
@@ -789,7 +791,7 @@ i386_linux_resume (struct target_ops *ops,
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;
diff --git a/gdb/i386-linux-tdep.c b/gdb/i386-linux-tdep.c
index e4c56f995d8..7928299a442 100644
--- a/gdb/i386-linux-tdep.c
+++ b/gdb/i386-linux-tdep.c
@@ -290,12 +290,14 @@ i386_linux_dwarf_signal_frame_p (struct gdbarch *gdbarch,
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)
@@ -320,7 +322,7 @@ i386_linux_sigcontext_addr (struct frame_info *this_frame)
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;
}
diff --git a/gdb/i386-nto-tdep.c b/gdb/i386-nto-tdep.c
index 0528931f072..aaa47f12970 100644
--- a/gdb/i386-nto-tdep.c
+++ b/gdb/i386-nto-tdep.c
@@ -293,12 +293,14 @@ i386nto_sigtramp_p (struct frame_info *this_frame)
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;
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index 8d5a5375699..1bb5ec2c5ae 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -414,6 +414,8 @@ i386_displaced_step_fixup (struct gdbarch *gdbarch,
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
@@ -521,9 +523,9 @@ i386_displaced_step_fixup (struct gdbarch *gdbarch,
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,
@@ -595,8 +597,9 @@ i386_alloc_frame_cache (void)
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;
@@ -605,7 +608,7 @@ i386_follow_jump (CORE_ADDR pc)
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)
@@ -614,7 +617,7 @@ i386_follow_jump (CORE_ADDR pc)
/* 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). */
@@ -622,7 +625,7 @@ i386_follow_jump (CORE_ADDR pc)
}
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;
@@ -630,7 +633,7 @@ i386_follow_jump (CORE_ADDR pc)
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;
@@ -1006,9 +1009,11 @@ i386_skip_noop (CORE_ADDR pc)
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;
@@ -1057,11 +1062,13 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
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:
@@ -1089,24 +1096,24 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
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
@@ -1117,7 +1124,7 @@ i386_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR limit,
}
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;
}
@@ -1182,15 +1189,16 @@ i386_analyze_register_saves (CORE_ADDR pc, CORE_ADDR current_pc,
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);
}
@@ -1199,6 +1207,8 @@ i386_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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 */
@@ -1210,7 +1220,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
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;
@@ -1243,7 +1253,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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;
@@ -1257,7 +1267,8 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
/* 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;
}
@@ -1266,8 +1277,8 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
/* 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;
}
@@ -1278,6 +1289,7 @@ i386_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_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);
@@ -1290,8 +1302,9 @@ i386_skip_main_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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
@@ -1321,6 +1334,8 @@ i386_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
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;
@@ -1341,7 +1356,7 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache)
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;
@@ -1350,13 +1365,14 @@ i386_frame_cache (struct frame_info *this_frame, void **this_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)
@@ -1381,7 +1397,8 @@ i386_frame_cache (struct frame_info *this_frame, void **this_cache)
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;
}
}
@@ -1477,8 +1494,10 @@ static const struct frame_unwind i386_frame_unwind =
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];
@@ -1488,7 +1507,7 @@ i386_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
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)
@@ -1612,6 +1631,7 @@ i386_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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
@@ -1620,15 +1640,15 @@ i386_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
@@ -1667,6 +1687,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1686,7 +1707,7 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
}
@@ -1735,11 +1756,11 @@ i386_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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. */
@@ -2500,11 +2521,17 @@ i386_regset_from_core_section (struct gdbarch *gdbarch,
/* 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;
@@ -2513,7 +2540,8 @@ i386_pe_skip_trampoline_code (CORE_ADDR pc, char *name)
{
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. */
@@ -2581,13 +2609,15 @@ i386_svr4_sigtramp_p (struct frame_info *this_frame)
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);
}
@@ -2704,8 +2734,10 @@ static CORE_ADDR
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
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 8b436d76788..b3fef438964 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -178,7 +178,8 @@ extern struct type *i387_ext_type (struct gdbarch *gdbarch);
#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. */
diff --git a/gdb/i386bsd-tdep.c b/gdb/i386bsd-tdep.c
index 87d33343ac6..b7e14135757 100644
--- a/gdb/i386bsd-tdep.c
+++ b/gdb/i386bsd-tdep.c
@@ -37,13 +37,15 @@
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);
}
diff --git a/gdb/i386nbsd-tdep.c b/gdb/i386nbsd-tdep.c
index bb6aaf0559e..be46b0ef8f6 100644
--- a/gdb/i386nbsd-tdep.c
+++ b/gdb/i386nbsd-tdep.c
@@ -234,6 +234,7 @@ i386nbsd_sigtramp_cache_init (const struct tramp_frame *self,
{
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;
@@ -246,7 +247,7 @@ i386nbsd_sigtramp_cache_init (const struct tramp_frame *self,
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
{
@@ -254,7 +255,7 @@ i386nbsd_sigtramp_cache_init (const struct tramp_frame *self,
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;
}
diff --git a/gdb/i386obsd-nat.c b/gdb/i386obsd-nat.c
index d2dac03b5dd..00a13cce92a 100644
--- a/gdb/i386obsd-nat.c
+++ b/gdb/i386obsd-nat.c
@@ -35,6 +35,8 @@
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:
@@ -76,8 +78,8 @@ i386obsd_supply_pcb (struct regcache *regcache, struct pcb *pcb)
{
/* 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);
}
diff --git a/gdb/i386obsd-tdep.c b/gdb/i386obsd-tdep.c
index d07ed0d4cd3..862183895d5 100644
--- a/gdb/i386obsd-tdep.c
+++ b/gdb/i386obsd-tdep.c
@@ -228,6 +228,8 @@ static void
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];
@@ -240,12 +242,12 @@ i386obsd_supply_uthread (struct regcache *regcache,
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);
}
@@ -257,7 +259,7 @@ i386obsd_supply_uthread (struct regcache *regcache,
/* 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);
@@ -270,6 +272,8 @@ static void
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];
@@ -285,10 +289,10 @@ i386obsd_collect_uthread (const struct regcache *regcache,
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. */
@@ -303,7 +307,7 @@ i386obsd_collect_uthread (const struct regcache *regcache,
/* 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);
@@ -339,6 +343,8 @@ static int i386obsd_tf_reg_offset[] =
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;
@@ -366,7 +372,7 @@ i386obsd_trapframe_cache (struct frame_info *this_frame, void **this_cache)
/* 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. */
diff --git a/gdb/i387-tdep.c b/gdb/i387-tdep.c
index 2444d5c1e21..073bb31ddda 100644
--- a/gdb/i387-tdep.c
+++ b/gdb/i387-tdep.c
@@ -389,7 +389,9 @@ static int fsave_offset[] =
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;
@@ -429,7 +431,7 @@ i387_supply_fsave (struct regcache *regcache, int regnum, const void *fsave)
{
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);
}
}
diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c
index 3a86c96f744..838bc0bf0d2 100644
--- a/gdb/ia64-linux-tdep.c
+++ b/gdb/ia64-linux-tdep.c
@@ -50,14 +50,16 @@ ia64_linux_pc_in_sigtramp (CORE_ADDR pc)
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);
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index abb36100792..a15be63d0e4 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -123,7 +123,8 @@ static gdbarch_register_type_ftype ia64_register_type;
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
@@ -824,6 +825,8 @@ static void
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
@@ -849,11 +852,13 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
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)
@@ -862,7 +867,8 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
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)
{
@@ -892,12 +898,13 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
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)
{
@@ -912,7 +919,8 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
/* 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)
{
@@ -934,7 +942,8 @@ ia64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
+ ((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));
@@ -944,6 +953,8 @@ static void
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;
@@ -964,7 +975,8 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
{
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;
@@ -988,7 +1000,8 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
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))
{
@@ -1012,12 +1025,13 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
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);
}
}
@@ -1042,7 +1056,8 @@ ia64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
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;
@@ -1365,8 +1380,10 @@ examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
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)
@@ -1571,6 +1588,9 @@ examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
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. */
@@ -1604,12 +1624,13 @@ examine_prologue (CORE_ADDR pc, CORE_ADDR lim_pc,
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;
@@ -1674,6 +1695,8 @@ ia64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -1686,19 +1709,19 @@ ia64_frame_cache (struct frame_info *this_frame, void **this_cache)
*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;
@@ -1743,6 +1766,7 @@ ia64_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 ia64_frame_cache *cache = ia64_frame_cache (this_frame, this_cache);
char buf[8];
@@ -1768,7 +1792,8 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
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));
@@ -1854,14 +1879,14 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
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;
}
@@ -1877,12 +1902,12 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **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);
}
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);
@@ -1900,17 +1925,17 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
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;
@@ -1951,11 +1976,11 @@ ia64_frame_prev_register (struct frame_info *this_frame, void **this_cache,
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));
@@ -2006,47 +2031,50 @@ static void
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];
@@ -2060,13 +2088,13 @@ ia64_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -2102,6 +2130,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *this_frame,
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);
@@ -2118,7 +2147,7 @@ ia64_sigtramp_frame_prev_register (struct frame_info *this_frame,
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);
@@ -2301,6 +2330,7 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
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];
@@ -2313,9 +2343,9 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
/* 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;
@@ -2324,9 +2354,9 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
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;
@@ -2335,13 +2365,13 @@ ia64_access_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *val,
/* 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;
}
@@ -2379,6 +2409,7 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *va
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];
@@ -2391,9 +2422,9 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *va
/* 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;
@@ -2402,9 +2433,9 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *va
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;
@@ -2413,13 +2444,13 @@ ia64_access_rse_reg (unw_addr_space_t as, unw_regnum_t uw_regnum, unw_word_t *va
/* 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;
}
@@ -2606,7 +2637,7 @@ ia64_find_unwind_table (struct objfile *objfile, unw_word_t ip,
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;
@@ -2732,6 +2763,7 @@ ia64_libunwind_frame_this_id (struct frame_info *this_frame, void **this_cache,
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;
@@ -2747,7 +2779,7 @@ ia64_libunwind_frame_this_id (struct frame_info *this_frame, void **this_cache,
/* 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);
@@ -2766,6 +2798,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame,
{
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)
@@ -2789,7 +2822,7 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame,
/* 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. */
@@ -2819,10 +2852,12 @@ ia64_libunwind_frame_prev_register (struct frame_info *this_frame,
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);
@@ -2859,6 +2894,7 @@ ia64_libunwind_sigtramp_frame_this_id (struct frame_info *this_frame,
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;
@@ -2874,7 +2910,7 @@ ia64_libunwind_sigtramp_frame_this_id (struct frame_info *this_frame,
/* 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);
@@ -2892,6 +2928,8 @@ static struct value *
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;
@@ -2899,7 +2937,8 @@ ia64_libunwind_sigtramp_frame_prev_register (struct frame_info *this_frame,
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)
{
@@ -3221,8 +3260,9 @@ slot_alignment_is_next_even (struct type *t)
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);
@@ -3252,7 +3292,7 @@ ia64_find_global_pointer (CORE_ADDR 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)
{
@@ -3261,7 +3301,8 @@ ia64_find_global_pointer (CORE_ADDR faddr)
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;
@@ -3281,8 +3322,9 @@ ia64_find_global_pointer (CORE_ADDR faddr)
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. */
@@ -3315,7 +3357,7 @@ find_extant_func_descr (CORE_ADDR faddr)
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;
@@ -3334,9 +3376,11 @@ find_extant_func_descr (CORE_ADDR faddr)
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)
{
@@ -3346,14 +3390,14 @@ find_func_descr (struct regcache *regcache, CORE_ADDR faddr, CORE_ADDR *fdaptr)
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);
}
@@ -3368,13 +3412,14 @@ static CORE_ADDR
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
@@ -3382,7 +3427,7 @@ ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
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))
@@ -3397,7 +3442,7 @@ ia64_convert_from_func_ptr_addr (struct gdbarch *gdbarch, CORE_ADDR addr,
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;
@@ -3415,6 +3460,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -3495,8 +3541,9 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
&& 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)
@@ -3556,7 +3603,7 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
@@ -3571,14 +3618,15 @@ ia64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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,
@@ -3592,13 +3640,14 @@ ia64_dummy_id (struct gdbarch *gdbarch, struct frame_info *this_frame)
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;
diff --git a/gdb/ia64-tdep.h b/gdb/ia64-tdep.h
index b098a5efef6..3822fa8a162 100644
--- a/gdb/ia64-tdep.h
+++ b/gdb/ia64-tdep.h
@@ -196,7 +196,7 @@
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. */
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 46d818d15ee..bfbc1e01707 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -90,8 +90,10 @@ static CORE_ADDR
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
@@ -108,11 +110,12 @@ static void
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: */
@@ -195,11 +198,13 @@ find_last_line_symbol (CORE_ADDR start, CORE_ADDR end, int notcurrent)
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;
@@ -234,7 +239,7 @@ iq2000_scan_prologue (CORE_ADDR scan_start,
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)
@@ -351,7 +356,7 @@ iq2000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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. */
@@ -361,6 +366,7 @@ iq2000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR 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;
@@ -379,7 +385,7 @@ iq2000_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -531,6 +537,9 @@ static void
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
@@ -551,7 +560,7 @@ iq2000_extract_return_value (struct type *type, struct regcache *regcache,
/* 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;
}
@@ -636,6 +645,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -767,7 +777,7 @@ iq2000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
}
diff --git a/gdb/irix5-nat.c b/gdb/irix5-nat.c
index 91ea948e3d9..42b4d5c426a 100644
--- a/gdb/irix5-nat.c
+++ b/gdb/irix5-nat.c
@@ -84,6 +84,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
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
@@ -94,7 +95,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
{
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)))
@@ -102,7 +103,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
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))
@@ -110,7 +111,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
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))
@@ -118,7 +119,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
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))
@@ -126,7 +127,7 @@ fill_gregset (const struct regcache *regcache, gregset_t *gregsetp, int regno)
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);
}
}
diff --git a/gdb/jv-lang.c b/gdb/jv-lang.c
index e1b6817a31b..6b68e7d6b0e 100644
--- a/gdb/jv-lang.c
+++ b/gdb/jv-lang.c
@@ -907,6 +907,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
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;
@@ -927,7 +928,7 @@ evaluate_subexp_java (struct type *expect_type, struct expression *exp,
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)"),
diff --git a/gdb/jv-valprint.c b/gdb/jv-valprint.c
index 72a617d4671..08d2e6fb3d5 100644
--- a/gdb/jv-valprint.c
+++ b/gdb/jv-valprint.c
@@ -39,6 +39,7 @@ java_value_print (struct value *val, struct ui_file *stream,
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;
@@ -81,7 +82,7 @@ java_value_print (struct value *val, struct ui_file *stream,
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)
@@ -110,7 +111,8 @@ java_value_print (struct value *val, struct ui_file *stream,
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++)
@@ -121,7 +123,8 @@ java_value_print (struct value *val, struct ui_file *stream,
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;
}
diff --git a/gdb/lm32-tdep.c b/gdb/lm32-tdep.c
index c949b791990..01a675da0e5 100644
--- a/gdb/lm32-tdep.c
+++ b/gdb/lm32-tdep.c
@@ -125,9 +125,11 @@ lm32_cannot_store_register (struct gdbarch *gdbarch, int regno)
/* 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
@@ -137,7 +139,7 @@ lm32_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
{
/* 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))
@@ -211,7 +213,7 @@ lm32_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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. */
@@ -235,6 +237,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -283,7 +286,7 @@ lm32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -309,6 +312,8 @@ static void
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;
@@ -319,7 +324,7 @@ lm32_extract_return_value (struct type *type, struct regcache *regcache,
{
/* 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))
{
@@ -345,19 +350,21 @@ static void
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
@@ -435,7 +442,8 @@ lm32_frame_cache (struct frame_info *this_frame, void **this_prologue_cache)
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);
diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c
index 9eb7257855d..c2a2f253e78 100644
--- a/gdb/m32c-tdep.c
+++ b/gdb/m32c-tdep.c
@@ -2003,6 +2003,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -2040,7 +2041,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
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. */
@@ -2061,7 +2062,8 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
}
@@ -2092,7 +2094,8 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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);
@@ -2178,6 +2181,7 @@ m32c_return_value (struct gdbarch *gdbarch,
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);
@@ -2200,7 +2204,7 @@ m32c_return_value (struct gdbarch *gdbarch,
{
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
{
@@ -2230,7 +2234,8 @@ m32c_return_value (struct gdbarch *gdbarch,
/* 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
@@ -2306,7 +2311,9 @@ m32c_return_value (struct gdbarch *gdbarch,
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,
@@ -2329,13 +2336,14 @@ m32c_skip_trampoline_code (struct frame_info *frame, CORE_ADDR stop_pc)
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;
}
}
@@ -2403,6 +2411,7 @@ static void
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);
@@ -2444,7 +2453,7 @@ m32c_m16c_address_to_pointer (struct gdbarch *gdbarch,
addr = SYMBOL_VALUE_ADDRESS (tramp_msym);
}
- store_unsigned_integer (buf, TYPE_LENGTH (type), addr);
+ store_unsigned_integer (buf, TYPE_LENGTH (type), byte_order, addr);
}
@@ -2452,13 +2461,14 @@ static CORE_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));
diff --git a/gdb/m32r-tdep.c b/gdb/m32r-tdep.c
index b5fc4cbcab8..b9556fac9dd 100644
--- a/gdb/m32r-tdep.c
+++ b/gdb/m32r-tdep.c
@@ -248,15 +248,18 @@ static void
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);
}
}
@@ -265,9 +268,11 @@ m32r_store_return_value (struct type *type, struct regcache *regcache,
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;
@@ -283,10 +288,10 @@ decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit,
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;
@@ -308,25 +313,30 @@ decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit,
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
@@ -452,6 +462,7 @@ decode_prologue (CORE_ADDR start_pc, CORE_ADDR scan_limit,
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;
@@ -478,11 +489,11 @@ m32r_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -669,6 +680,7 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -713,7 +725,8 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -741,7 +754,8 @@ m32r_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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);
}
@@ -767,6 +781,8 @@ static void
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;
@@ -774,14 +790,14 @@ m32r_extract_return_value (struct type *type, struct regcache *regcache,
/* 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);
}
}
diff --git a/gdb/m68hc11-tdep.c b/gdb/m68hc11-tdep.c
index 30824295fad..2202c690246 100644
--- a/gdb/m68hc11-tdep.c
+++ b/gdb/m68hc11-tdep.c
@@ -284,6 +284,8 @@ m68hc11_pseudo_register_read (struct gdbarch *gdbarch,
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)
@@ -301,7 +303,7 @@ m68hc11_pseudo_register_read (struct gdbarch *gdbarch,
pc += (page << 14);
pc += 0x1000000;
}
- store_unsigned_integer (buf, regsize, pc);
+ store_unsigned_integer (buf, regsize, byte_order, pc);
return;
}
@@ -325,6 +327,8 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
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)
@@ -334,7 +338,7 @@ m68hc11_pseudo_register_write (struct gdbarch *gdbarch,
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;
@@ -497,9 +501,11 @@ static struct insn_sequence m6812_prologue[] = {
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;
@@ -515,7 +521,7 @@ m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR pc,
if (bufsize < j + 1)
{
buffer[bufsize] = read_memory_unsigned_integer (pc + bufsize,
- 1);
+ 1, byte_order);
bufsize++;
}
/* Continue while we match the opcode. */
@@ -551,13 +557,13 @@ m68hc11_analyze_instruction (struct insn_sequence *seq, CORE_ADDR pc,
}
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;
@@ -678,7 +684,7 @@ m68hc11_scan_prologue (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -1158,6 +1164,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1180,7 +1187,8 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
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);
@@ -1211,7 +1219,7 @@ m68hc11_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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... */
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 213431f9f10..507af653dab 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -495,6 +495,7 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -522,17 +523,17 @@ m68k_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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. */
@@ -613,15 +614,17 @@ m68k_alloc_frame_cache (void)
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)
{
@@ -631,14 +634,14 @@ m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
{
/* 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;
}
}
@@ -648,7 +651,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
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
@@ -658,7 +661,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
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)
{
@@ -677,7 +680,7 @@ m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
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;
@@ -690,13 +693,13 @@ m68k_analyze_frame_setup (CORE_ADDR pc, CORE_ADDR current_pc,
{
/* 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;
}
@@ -713,6 +716,8 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -722,12 +727,12 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -755,7 +760,7 @@ m68k_analyze_register_saves (struct gdbarch *gdbarch, CORE_ADDR pc,
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)
@@ -811,15 +816,16 @@ static CORE_ADDR
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 */
@@ -859,6 +865,8 @@ m68k_unwind_pc (struct gdbarch *gdbarch, struct frame_info *next_frame)
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;
@@ -879,7 +887,7 @@ m68k_frame_cache (struct frame_info *this_frame, void **this_cache)
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;
@@ -902,7 +910,8 @@ m68k_frame_cache (struct frame_info *this_frame, void **this_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
@@ -998,7 +1007,8 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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)
{
@@ -1015,14 +1025,15 @@ m68k_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
diff --git a/gdb/m68klinux-tdep.c b/gdb/m68klinux-tdep.c
index 5813ee583da..0e8edc8b073 100644
--- a/gdb/m68klinux-tdep.c
+++ b/gdb/m68klinux-tdep.c
@@ -65,6 +65,8 @@
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;
@@ -72,14 +74,14 @@ m68k_linux_pc_in_sigtramp (struct frame_info *this_frame)
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))
@@ -222,6 +224,8 @@ m68k_linux_inferior_created (struct target_ops *objfile, int from_tty)
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;
@@ -239,7 +243,7 @@ m68k_linux_get_sigtramp_info (struct frame_info *this_frame)
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;
@@ -258,7 +262,9 @@ m68k_linux_sigtramp_frame_cache (struct frame_info *this_frame,
{
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;
@@ -274,8 +280,8 @@ m68k_linux_sigtramp_frame_cache (struct frame_info *this_frame,
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);
diff --git a/gdb/m88k-tdep.c b/gdb/m88k-tdep.c
index b1b0cfba11c..6514fe63602 100644
--- a/gdb/m88k-tdep.c
+++ b/gdb/m88k-tdep.c
@@ -39,9 +39,9 @@
/* 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. */
@@ -526,9 +526,11 @@ struct m88k_prologue_insn m88k_prologue_insn_table[] =
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. */
@@ -548,7 +550,7 @@ m88k_analyze_prologue (CORE_ADDR pc, CORE_ADDR limit,
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++;
@@ -643,12 +645,14 @@ m88k_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -661,7 +665,8 @@ m88k_frame_cache (struct frame_info *this_frame, void **this_cache)
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)
diff --git a/gdb/mep-tdep.c b/gdb/mep-tdep.c
index ee359f9e419..3d2b6663fbd 100644
--- a/gdb/mep-tdep.c
+++ b/gdb/mep-tdep.c
@@ -1139,6 +1139,7 @@ mep_pseudo_cr32_read (struct gdbarch *gdbarch,
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];
@@ -1148,7 +1149,8 @@ mep_pseudo_cr32_read (struct gdbarch *gdbarch,
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));
}
@@ -1188,6 +1190,7 @@ mep_pseudo_csr_write (struct gdbarch *gdbarch,
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];
@@ -1204,7 +1207,7 @@ mep_pseudo_csr_write (struct gdbarch *gdbarch,
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);
@@ -1218,6 +1221,7 @@ mep_pseudo_cr32_write (struct gdbarch *gdbarch,
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];
@@ -1226,7 +1230,8 @@ mep_pseudo_cr32_write (struct gdbarch *gdbarch,
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);
}
@@ -1415,8 +1420,9 @@ mep_pc_in_vliw_section (CORE_ADDR pc)
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;
@@ -1453,7 +1459,7 @@ mep_get_insn (CORE_ADDR pc, long *insn)
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
@@ -1463,7 +1469,7 @@ mep_get_insn (CORE_ADDR pc, long *insn)
{
/* 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
@@ -1700,7 +1706,7 @@ mep_analyze_prologue (struct gdbarch *gdbarch,
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
@@ -2294,6 +2300,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -2334,7 +2341,8 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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. */
@@ -2350,7 +2358,7 @@ mep_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
}
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 3d4281f37bd..6aa1d08db99 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -1030,6 +1030,8 @@ mi_cmd_data_read_memory (char *command, char **argv, int argc)
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;
@@ -1087,7 +1089,7 @@ mi_cmd_data_write_memory (char *command, char **argv, int argc)
/* 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. */
diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c
index 7f4c1b14e99..56401e5b637 100644
--- a/gdb/mips-linux-tdep.c
+++ b/gdb/mips-linux-tdep.c
@@ -55,6 +55,7 @@ mips_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
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);
@@ -65,7 +66,8 @@ mips_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
@@ -77,10 +79,11 @@ mips_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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);
}
@@ -258,6 +261,7 @@ mips64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
{
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;
@@ -269,7 +273,8 @@ mips64_linux_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
@@ -343,6 +348,7 @@ mips64_fill_gregset (const struct regcache *regcache,
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;
@@ -388,9 +394,10 @@ mips64_fill_gregset (const struct regcache *regcache,
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);
}
}
@@ -440,6 +447,7 @@ mips64_fill_fpregset (const struct regcache *regcache,
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))
@@ -468,9 +476,10 @@ mips64_fill_fpregset (const struct regcache *regcache,
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)
{
@@ -478,9 +487,10 @@ mips64_fill_fpregset (const struct regcache *regcache,
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)
{
@@ -605,6 +615,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
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);
@@ -622,7 +633,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
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;
@@ -630,7 +641,7 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
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 */
@@ -644,12 +655,12 @@ mips_linux_in_dynsym_stub (CORE_ADDR pc, char *name)
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 */
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index ad0076d0b8e..e2ecc8b1ad6 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -880,8 +880,9 @@ mips_write_pc (struct regcache *regcache, CORE_ADDR pc)
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;
@@ -896,7 +897,7 @@ mips_fetch_instruction (CORE_ADDR addr)
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 */
@@ -927,9 +928,10 @@ mips32_relative_offset (ULONGEST inst)
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)
@@ -1151,16 +1153,17 @@ extended_offset (unsigned int extension)
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)
@@ -1228,7 +1231,7 @@ unpack_mips16 (CORE_ADDR pc,
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;
@@ -1254,6 +1257,7 @@ static CORE_ADDR
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)
{
@@ -1261,7 +1265,7 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
{
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)
{
@@ -1274,7 +1278,7 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
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 */
@@ -1286,7 +1290,7 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
{
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;
@@ -1298,7 +1302,7 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
{
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;
@@ -1310,7 +1314,7 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
{
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 */
@@ -1358,7 +1362,8 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
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:
@@ -1373,7 +1378,8 @@ extended_mips16_next_pc (struct frame_info *frame, CORE_ADDR pc,
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);
}
@@ -1463,7 +1469,8 @@ mips16_get_imm (unsigned short prev_inst, /* previous instruction */
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)
{
@@ -1482,7 +1489,6 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
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. */
@@ -1503,7 +1509,7 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
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
@@ -1769,6 +1775,7 @@ mips16_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
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)
@@ -1784,19 +1791,18 @@ mips_insn16_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -1891,7 +1897,8 @@ reset_saved_regs (struct gdbarch *gdbarch, struct mips_frame_cache *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)
{
@@ -1905,7 +1912,6 @@ mips32_scan_prologue (CORE_ADDR start_pc, CORE_ADDR limit_pc,
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
@@ -1929,7 +1935,7 @@ restart:
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;
@@ -2117,6 +2123,7 @@ restart:
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)
@@ -2133,19 +2140,18 @@ mips_insn32_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -2391,7 +2397,7 @@ deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -2402,7 +2408,7 @@ deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)
{
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
@@ -2495,7 +2501,7 @@ mips_software_single_step (struct frame_info *frame)
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
@@ -2504,9 +2510,9 @@ mips_about_to_return (CORE_ADDR pc)
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 */
}
@@ -2589,12 +2595,12 @@ heuristic-fence-post' command.\n",
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;
}
@@ -2612,7 +2618,7 @@ heuristic-fence-post' command.\n",
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;
@@ -2697,6 +2703,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
@@ -2765,7 +2772,8 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -2813,14 +2821,16 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *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, 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));
@@ -2832,7 +2842,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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));
@@ -2919,7 +2929,7 @@ mips_eabi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
&& !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",
@@ -3084,6 +3094,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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
@@ -3161,7 +3172,7 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *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));
@@ -3175,7 +3186,8 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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));
@@ -3275,9 +3287,11 @@ mips_n32n64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
|| (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
@@ -3522,6 +3536,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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
@@ -3624,7 +3639,8 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *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));
@@ -3635,7 +3651,8 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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));
@@ -3652,7 +3669,7 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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));
@@ -3740,7 +3757,8 @@ mips_o32_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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(). */
@@ -3982,6 +4000,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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
@@ -4063,7 +4082,7 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *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));
@@ -4145,7 +4164,8 @@ mips_o64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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(). */
@@ -4649,6 +4669,7 @@ static int
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];
@@ -4663,7 +4684,7 @@ mips_single_step_through_delay (struct gdbarch *gdbarch,
/* 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
@@ -4703,15 +4724,15 @@ mips_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -4730,7 +4751,7 @@ mips32_in_function_epilogue_p (CORE_ADDR pc)
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 */
@@ -4749,7 +4770,7 @@ mips32_in_function_epilogue_p (CORE_ADDR pc)
/* 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;
@@ -4767,7 +4788,7 @@ mips16_in_function_epilogue_p (CORE_ADDR pc)
{
unsigned short inst;
- inst = mips_fetch_instruction (pc);
+ inst = mips_fetch_instruction (gdbarch, pc);
if ((inst & 0xf800) == 0xf000) /* extend */
continue;
@@ -4792,9 +4813,9 @@ static int
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
@@ -5077,6 +5098,7 @@ mips_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
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;
@@ -5135,7 +5157,7 @@ mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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 */
@@ -5161,6 +5183,8 @@ mips_skip_mips16_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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];
@@ -5186,7 +5210,8 @@ mips_skip_pic_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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)
@@ -5298,7 +5323,8 @@ static CORE_ADDR
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
diff --git a/gdb/mipsnbsd-tdep.c b/gdb/mipsnbsd-tdep.c
index b9e05473186..e690322f16a 100644
--- a/gdb/mipsnbsd-tdep.c
+++ b/gdb/mipsnbsd-tdep.c
@@ -294,6 +294,7 @@ static int
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;
@@ -305,8 +306,8 @@ mipsnbsd_get_longjmp_target (struct frame_info *frame, CORE_ADDR *pc)
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;
}
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index a110798752c..caf6557b9c6 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -387,6 +387,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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];
@@ -545,7 +546,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -562,7 +563,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -580,7 +581,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -594,7 +595,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -615,7 +616,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -635,7 +636,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -722,7 +723,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -746,7 +747,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -770,7 +771,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -793,7 +794,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -816,7 +817,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -839,7 +840,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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),
@@ -887,7 +888,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -912,7 +913,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -937,7 +938,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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);
@@ -952,7 +953,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -968,7 +969,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
}
@@ -983,7 +984,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
}
@@ -993,7 +994,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -1009,7 +1010,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
}
@@ -1024,7 +1025,7 @@ mn10300_analyze_prologue (struct gdbarch *gdbarch,
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;
}
@@ -1223,6 +1224,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -1270,7 +1272,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
{
/* 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];
}
@@ -1283,7 +1285,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
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++;
@@ -1305,7 +1307,7 @@ mn10300_push_dummy_call (struct gdbarch *gdbarch,
/* 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". */
diff --git a/gdb/monitor.c b/gdb/monitor.c
index a148eafce02..1e61afdebbd 100644
--- a/gdb/monitor.c
+++ b/gdb/monitor.c
@@ -870,6 +870,8 @@ monitor_detach (struct target_ops *ops, char *args, int from_tty)
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;
@@ -905,8 +907,7 @@ monitor_supply_register (struct regcache *regcache, int regno, char *valstr)
/* 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);
@@ -1409,6 +1410,7 @@ monitor_files_info (struct target_ops *ops)
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;
@@ -1465,7 +1467,7 @@ monitor_write_memory (CORE_ADDR memaddr, char *myaddr, int len)
cmd = current_monitor->setmem.cmdb;
}
- val = extract_unsigned_integer (myaddr, len);
+ val = extract_unsigned_integer (myaddr, len, byte_order);
if (len == 4)
{
@@ -1670,6 +1672,7 @@ monitor_write_memory_block (CORE_ADDR memaddr, char *myaddr, int len)
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;
@@ -1786,7 +1789,7 @@ monitor_read_memory_single (CORE_ADDR memaddr, char *myaddr, int len)
/* 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;
}
diff --git a/gdb/moxie-tdep.c b/gdb/moxie-tdep.c
index 93ba07c5f26..200365792c7 100644
--- a/gdb/moxie-tdep.c
+++ b/gdb/moxie-tdep.c
@@ -120,15 +120,18 @@ static void
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);
}
}
@@ -144,6 +147,8 @@ moxie_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
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;
@@ -159,7 +164,7 @@ moxie_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
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)
@@ -174,8 +179,8 @@ moxie_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
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 */
{
@@ -297,6 +302,8 @@ static void
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;
@@ -304,14 +311,14 @@ moxie_extract_return_value (struct type *type, struct regcache *regcache,
/* 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);
}
}
diff --git a/gdb/mt-tdep.c b/gdb/mt-tdep.c
index b0da869aab2..58fc4912648 100644
--- a/gdb/mt-tdep.c
+++ b/gdb/mt-tdep.c
@@ -339,6 +339,8 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
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,
@@ -369,7 +371,8 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
/* 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)
@@ -403,6 +406,7 @@ mt_return_value (struct gdbarch *gdbarch, struct type *func_type,
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;
@@ -430,7 +434,7 @@ mt_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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 */
@@ -474,13 +478,15 @@ static int
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;
@@ -491,8 +497,10 @@ mt_select_coprocessor (struct gdbarch *gdbarch,
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. */
@@ -519,6 +527,8 @@ static void
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:
@@ -537,7 +547,7 @@ mt_pseudo_register_read (struct gdbarch *gdbarch,
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);
@@ -567,6 +577,7 @@ mt_pseudo_register_write (struct gdbarch *gdbarch,
struct regcache *regcache,
int regno, const gdb_byte *buf)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int i;
switch (regno)
@@ -587,7 +598,7 @@ mt_pseudo_register_write (struct gdbarch *gdbarch,
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);
@@ -626,6 +637,8 @@ mt_registers_info (struct gdbarch *gdbarch,
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;
@@ -672,10 +685,10 @@ mt_registers_info (struct gdbarch *gdbarch,
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
@@ -709,13 +722,13 @@ mt_registers_info (struct gdbarch *gdbarch,
/* 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;
@@ -755,6 +768,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -778,7 +792,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
regcache_cooked_write_unsigned (regcache, argreg++,
extract_unsigned_integer
(value_contents (args[i]),
- wordsize));
+ wordsize, byte_order));
break;
case 8:
case 12:
@@ -791,7 +805,7 @@ mt_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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;
}
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index a67ba37047b..0e4fb71965b 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -1610,58 +1610,69 @@ _initialize_objc_language (void)
}
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)
@@ -1670,7 +1681,7 @@ find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
struct objc_class class_str;
unsigned mlistnum = 0;
- read_objc_class (subclass, &class_str);
+ read_objc_class (gdbarch, subclass, &class_str);
for (;;)
{
@@ -1679,16 +1690,17 @@ find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
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,
@@ -1710,17 +1722,18 @@ find_implementation_from_class (CORE_ADDR class, CORE_ADDR sel)
}
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
@@ -1737,7 +1750,7 @@ resolve_msgsend (CORE_ADDR pc, CORE_ADDR *new_pc)
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)
@@ -1759,7 +1772,7 @@ resolve_msgsend_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
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)
@@ -1783,11 +1796,11 @@ resolve_msgsend_super (CORE_ADDR pc, CORE_ADDR *new_pc)
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)
@@ -1811,11 +1824,11 @@ resolve_msgsend_super_stret (CORE_ADDR pc, CORE_ADDR *new_pc)
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)
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index e743a6f812c..1722c0f4e03 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -217,6 +217,7 @@ pascal_printstr (struct ui_file *stream, struct type *type,
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;
@@ -227,7 +228,8 @@ pascal_printstr (struct ui_file *stream, struct type *type,
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)
@@ -253,13 +255,14 @@ pascal_printstr (struct ui_file *stream, struct type *type,
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;
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index ec90016b55d..50c993f8404 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -57,6 +57,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
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;
@@ -95,7 +96,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
/* 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;
@@ -143,9 +145,9 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
/* 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));
@@ -193,7 +195,8 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
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);
}
@@ -294,7 +297,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
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
@@ -302,7 +305,7 @@ pascal_val_print (struct type *type, const gdb_byte *valaddr,
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
diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c
index 297365bfa64..2447cc0ad12 100644
--- a/gdb/ppc-linux-nat.c
+++ b/gdb/ppc-linux-nat.c
@@ -1523,6 +1523,7 @@ ppc_linux_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
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)
@@ -1531,9 +1532,9 @@ ppc_linux_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
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;
diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c
index 2bb88b36ceb..d102db44762 100644
--- a/gdb/ppc-linux-tdep.c
+++ b/gdb/ppc-linux-tdep.c
@@ -329,10 +329,11 @@ insn_ds_field (unsigned int insn)
/* 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);
}
@@ -483,7 +484,8 @@ static CORE_ADDR
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. */
@@ -494,7 +496,7 @@ ppc64_standard_linkage1_target (struct frame_info *frame,
+ 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[] =
@@ -525,7 +527,8 @@ static CORE_ADDR
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. */
@@ -536,14 +539,15 @@ ppc64_standard_linkage2_target (struct frame_info *frame,
+ 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. */
@@ -553,7 +557,7 @@ ppc64_standard_linkage3_target (struct frame_info *frame,
+ 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);
}
@@ -621,6 +625,7 @@ ppc64_linux_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 target_section *s = target_section_by_addr (targ, addr);
/* Check if ADDR points to a function descriptor. */
@@ -652,7 +657,7 @@ ppc64_linux_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
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;
}
@@ -847,6 +852,7 @@ ppc_linux_sigtramp_cache (struct frame_info *this_frame,
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));
@@ -859,7 +865,7 @@ ppc_linux_sigtramp_cache (struct frame_info *this_frame,
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. */
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 3d5a7dbb8e4..703ca4db40a 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -49,6 +49,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -398,13 +399,13 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -462,7 +463,7 @@ ppc_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -556,6 +557,7 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *type,
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
@@ -675,7 +677,8 @@ do_ppc_sysv_return_value (struct gdbarch *gdbarch, struct type *type,
ULONGEST regval;
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
&regval);
- store_unsigned_integer (readbuf, TYPE_LENGTH (type), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (type), byte_order,
+ regval);
}
if (writebuf)
{
@@ -892,6 +895,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
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;
@@ -1194,7 +1198,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
@@ -1315,7 +1319,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -1330,7 +1334,7 @@ ppc64_sysv_abi_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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);
}
@@ -1356,6 +1360,7 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *func_type,
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
@@ -1402,7 +1407,8 @@ ppc64_sysv_abi_return_value (struct gdbarch *gdbarch, struct type *func_type,
ULONGEST regval;
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
&regval);
- store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+ regval);
}
return RETURN_VALUE_REGISTER_CONVENTION;
}
diff --git a/gdb/ppcobsd-tdep.c b/gdb/ppcobsd-tdep.c
index 255579cf5c7..b7520a52d18 100644
--- a/gdb/ppcobsd-tdep.c
+++ b/gdb/ppcobsd-tdep.c
@@ -126,6 +126,8 @@ ppcobsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
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;
@@ -145,12 +147,13 @@ ppcobsd_sigtramp_frame_sniffer (const struct frame_unwind *self,
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;
@@ -165,6 +168,7 @@ ppcobsd_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;
CORE_ADDR addr, base, func;
gdb_byte buf[PPC_INSN_SIZE];
@@ -185,7 +189,7 @@ ppcobsd_sigtramp_frame_cache (struct frame_info *this_frame, void **this_cache)
/* 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));
diff --git a/gdb/printcmd.c b/gdb/printcmd.c
index 8a8a51b7f4e..5d8b936a6c1 100644
--- a/gdb/printcmd.c
+++ b/gdb/printcmd.c
@@ -2282,6 +2282,7 @@ printf_command (char *arg, int from_tty)
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);
@@ -2296,7 +2297,7 @@ printf_command (char *arg, int from_tty)
{
QUIT;
read_memory (tem + j, buf, wcwidth);
- if (extract_unsigned_integer (buf, wcwidth) == 0)
+ if (extract_unsigned_integer (buf, wcwidth, byte_order) == 0)
break;
}
@@ -2309,7 +2310,7 @@ printf_command (char *arg, int from_tty)
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);
@@ -2323,6 +2324,7 @@ printf_command (char *arg, int from_tty)
{
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;
@@ -2340,7 +2342,7 @@ printf_command (char *arg, int from_tty)
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),
@@ -2431,6 +2433,7 @@ printf_command (char *arg, int from_tty)
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;
@@ -2490,18 +2493,19 @@ printf_command (char *arg, int from_tty)
/* 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);
diff --git a/gdb/procfs.c b/gdb/procfs.c
index 378042dbeed..80479e35170 100644
--- a/gdb/procfs.c
+++ b/gdb/procfs.c
@@ -162,6 +162,7 @@ static int
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)
@@ -170,11 +171,11 @@ procfs_auxv_parse (struct target_ops *ops, gdb_byte **readptr,
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;
diff --git a/gdb/python/python-value.c b/gdb/python/python-value.c
index d4353f7e881..5304cafa2a6 100644
--- a/gdb/python/python-value.c
+++ b/gdb/python/python-value.c
@@ -573,7 +573,8 @@ valpy_nonzero (PyObject *self)
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 "
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 2bea4e2cc2f..c921bddd536 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -570,8 +570,9 @@ regcache_raw_read_signed (struct regcache *regcache, int regnum, LONGEST *val)
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
@@ -583,8 +584,9 @@ regcache_raw_read_unsigned (struct regcache *regcache, int regnum,
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
@@ -594,7 +596,8 @@ regcache_raw_write_signed (struct regcache *regcache, int regnum, LONGEST val)
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);
}
@@ -606,7 +609,8 @@ regcache_raw_write_unsigned (struct regcache *regcache, int regnum,
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);
}
@@ -637,8 +641,9 @@ regcache_cooked_read_signed (struct regcache *regcache, int regnum,
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
@@ -650,8 +655,9 @@ regcache_cooked_read_unsigned (struct regcache *regcache, int regnum,
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
@@ -662,7 +668,8 @@ regcache_cooked_write_signed (struct regcache *regcache, int regnum,
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);
}
@@ -674,7 +681,8 @@ regcache_cooked_write_unsigned (struct regcache *regcache, int regnum,
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);
}
diff --git a/gdb/remote-m32r-sdi.c b/gdb/remote-m32r-sdi.c
index 34e2da0df13..814faf064c3 100644
--- a/gdb/remote-m32r-sdi.c
+++ b/gdb/remote-m32r-sdi.c
@@ -917,6 +917,8 @@ static void
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)
@@ -947,7 +949,7 @@ m32r_fetch_register (struct target_ops *ops,
/* 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;
diff --git a/gdb/remote-mips.c b/gdb/remote-mips.c
index ea6e8192ef5..332d21ef69d 100644
--- a/gdb/remote-mips.c
+++ b/gdb/remote-mips.c
@@ -93,7 +93,7 @@ static void mips_prepare_to_store (struct regcache *regcache);
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,
@@ -1749,26 +1749,27 @@ mips_wait (struct target_ops *ops,
{
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);
@@ -1899,6 +1900,7 @@ mips_fetch_registers (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 LONGEST val;
int err;
@@ -1943,7 +1945,8 @@ mips_fetch_registers (struct target_ops *ops,
/* 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);
}
}
@@ -2007,7 +2010,7 @@ mips_fetch_word (CORE_ADDR addr)
/* 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;
@@ -2023,7 +2026,7 @@ mips_store_word (CORE_ADDR addr, unsigned int val, char *old_contents)
return errno;
}
if (old_contents != NULL)
- store_unsigned_integer (old_contents, 4, oldcontents);
+ *old_contents = oldcontents;
return 0;
}
@@ -2040,6 +2043,7 @@ static int
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;
@@ -2064,14 +2068,15 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
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));
}
@@ -2083,9 +2088,9 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
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)
{
@@ -2107,7 +2112,8 @@ mips_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write,
/* 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;
}
diff --git a/gdb/rs6000-aix-tdep.c b/gdb/rs6000-aix-tdep.c
index e3c5c1a95ed..643d625dbe7 100644
--- a/gdb/rs6000-aix-tdep.c
+++ b/gdb/rs6000-aix-tdep.c
@@ -194,6 +194,7 @@ rs6000_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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 */
@@ -404,7 +405,7 @@ ran_out_of_registers_for_arguments:
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
@@ -429,6 +430,7 @@ rs6000_return_value (struct gdbarch *gdbarch, struct type *func_type,
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
@@ -500,7 +502,8 @@ rs6000_return_value (struct gdbarch *gdbarch, struct type *func_type,
/* For reading we don't have to worry about sign extension. */
regcache_cooked_read_unsigned (regcache, tdep->ppc_gp0_regnum + 3,
&regval);
- store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), regval);
+ store_unsigned_integer (readbuf, TYPE_LENGTH (valtype), byte_order,
+ regval);
}
if (writebuf)
{
@@ -567,6 +570,8 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
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);
@@ -578,7 +583,7 @@ rs6000_convert_from_func_ptr_addr (struct gdbarch *gdbarch,
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))
@@ -595,7 +600,9 @@ static CORE_ADDR
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;
@@ -635,7 +642,7 @@ branch_dest (struct frame_info *frame, int opcode, int instr,
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 */
@@ -664,6 +671,7 @@ static int
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];
@@ -671,7 +679,7 @@ rs6000_software_single_step (struct frame_info *frame)
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;
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index e23d455c4f5..d21e87bc966 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -874,6 +874,7 @@ static int
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;
@@ -898,7 +899,7 @@ rs6000_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
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
@@ -924,7 +925,7 @@ rs6000_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
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;
}
@@ -971,10 +972,11 @@ ppc_displaced_step_fixup (struct gdbarch *gdbarch,
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;
@@ -1072,11 +1074,12 @@ int
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). */
@@ -1094,7 +1097,7 @@ ppc_deal_with_atomic_sequence (struct frame_info *frame)
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
@@ -1129,7 +1132,7 @@ ppc_deal_with_atomic_sequence (struct frame_info *frame)
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;
@@ -1240,7 +1243,7 @@ store_param_on_stack_p (unsigned long op, int framep, int *r0_contains_arg)
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;
@@ -1254,7 +1257,7 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int insn)
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;
@@ -1276,15 +1279,16 @@ bl_to_blrl_insn_p (CORE_ADDR pc, int insn)
#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;
}
@@ -1295,10 +1299,10 @@ rs6000_fetch_instruction (const CORE_ADDR pc)
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)
@@ -1310,7 +1314,7 @@ rs6000_skip_stack_check (const CORE_ADDR start_pc)
while ((op & 0xffff0000) == 0x90010000)
{
pc = pc + 4;
- op = rs6000_fetch_instruction (pc);
+ op = rs6000_fetch_instruction (gdbarch, pc);
}
return pc;
}
@@ -1336,17 +1340,17 @@ rs6000_skip_stack_check (const CORE_ADDR start_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)
@@ -1354,41 +1358,41 @@ rs6000_skip_stack_check (const CORE_ADDR start_pc)
/* 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. */
@@ -1425,26 +1429,26 @@ rs6000_skip_stack_check (const CORE_ADDR start_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;
@@ -1504,6 +1508,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
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;
@@ -1515,7 +1520,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
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;
@@ -1537,7 +1542,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR 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 */
@@ -1709,7 +1714,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
/* 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;
@@ -1729,7 +1734,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
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,
@@ -2047,7 +2052,7 @@ skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR lim_pc,
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) */
@@ -2112,12 +2117,13 @@ rs6000_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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)
{
@@ -2168,7 +2174,8 @@ rs6000_frame_align (struct gdbarch *gdbarch, CORE_ADDR addr)
@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);
}
@@ -2190,7 +2197,9 @@ rs6000_in_solib_return_trampoline (CORE_ADDR pc, char *name)
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;
@@ -2211,10 +2220,11 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR 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
@@ -2231,12 +2241,12 @@ rs6000_skip_trampoline_code (struct frame_info *frame, CORE_ADDR pc)
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;
}
@@ -3039,6 +3049,7 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache)
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;
@@ -3096,7 +3107,8 @@ rs6000_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 4670d507832..87bf733d686 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -166,18 +166,19 @@ static void
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:
@@ -189,19 +190,20 @@ static void
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);
@@ -216,6 +218,7 @@ static void
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)
@@ -226,7 +229,7 @@ s390x_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
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:
@@ -238,6 +241,7 @@ static void
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)
@@ -247,7 +251,7 @@ s390x_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
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);
@@ -677,9 +681,10 @@ struct s390_prologue_data {
/* 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];
@@ -777,7 +782,8 @@ s390_load (struct s390_prologue_data *data,
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. */
@@ -864,6 +870,7 @@ s390_analyze_prologue (struct gdbarch *gdbarch,
(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);
@@ -1356,20 +1363,22 @@ s390_backchain_frame_unwind_cache (struct frame_info *this_frame,
{
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
@@ -1540,6 +1549,7 @@ s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
{
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;
@@ -1570,7 +1580,8 @@ s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
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:
@@ -1617,7 +1628,7 @@ s390_sigtramp_frame_unwind_cache (struct frame_info *this_frame,
/* 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;
@@ -1910,8 +1921,9 @@ s390_function_arg_integer (struct type *type)
/* 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
@@ -1919,10 +1931,10 @@ extend_simple_arg (struct value *arg)
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);
}
@@ -1985,6 +1997,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
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;
@@ -2050,7 +2063,8 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
}
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;
}
}
@@ -2080,14 +2094,14 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
{
/* 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;
}
}
@@ -2182,6 +2196,7 @@ s390_return_value (struct gdbarch *gdbarch, struct type *func_type,
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 =
@@ -2204,10 +2219,10 @@ s390_return_value (struct gdbarch *gdbarch, struct type *func_type,
/* 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)
{
diff --git a/gdb/scm-exp.c b/gdb/scm-exp.c
index 8b7be2a3cde..1dd16159425 100644
--- a/gdb/scm-exp.c
+++ b/gdb/scm-exp.c
@@ -312,7 +312,8 @@ tryagain:
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;
diff --git a/gdb/scm-lang.c b/gdb/scm-lang.c
index bc37c6f7e68..de348940bab 100644
--- a/gdb/scm-lang.c
+++ b/gdb/scm-lang.c
@@ -68,11 +68,12 @@ is_scmvalue_type (struct type *type)
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
@@ -84,7 +85,10 @@ scm_unpack (struct type *type, const gdb_byte *valaddr, enum type_code context)
{
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)
diff --git a/gdb/scm-lang.h b/gdb/scm-lang.h
index 5c2680e7289..0d120d399bc 100644
--- a/gdb/scm-lang.h
+++ b/gdb/scm-lang.h
@@ -35,8 +35,8 @@
#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))
@@ -52,7 +52,7 @@ extern int scm_val_print (struct type *, const gdb_byte *, int, CORE_ADDR,
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 *);
diff --git a/gdb/scm-valprint.c b/gdb/scm-valprint.c
index d074a51067a..cc3319ab6fb 100644
--- a/gdb/scm-valprint.c
+++ b/gdb/scm-valprint.c
@@ -133,6 +133,7 @@ scm_scmlist_print (struct type *type, LONGEST svalue,
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)
{
@@ -158,6 +159,7 @@ scm_scmlist_print (struct type *type, LONGEST svalue,
fputs_filtered (" . ", stream);
scm_scmval_print (type, svalue, stream, recurse + 1, options);
}
+#undef SCM_BYTE_ORDER
#undef SCM_SIZE
}
@@ -166,11 +168,13 @@ scm_ipruk (char *hdr, struct type *type, LONGEST ptr,
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
}
@@ -182,6 +186,7 @@ scm_scmval_print (struct type *type, LONGEST svalue,
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)
{
@@ -307,13 +312,14 @@ taloop:
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);
}
@@ -403,6 +409,7 @@ taloop:
}
break;
}
+#undef SCM_BYTE_ORDER
#undef SCM_SIZE
}
@@ -414,7 +421,9 @@ scm_val_print (struct type *type, const gdb_byte *valaddr,
{
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)
{
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index e54f33c66d2..50fd5af20d6 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -324,6 +324,7 @@ static const gdb_byte *
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;
@@ -333,9 +334,9 @@ score_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
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))
{
@@ -476,6 +477,7 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -553,7 +555,8 @@ score_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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. */
@@ -642,6 +645,7 @@ score_adjust_memblock_ptr (char **memblock, CORE_ADDR prev_pc,
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;
@@ -664,10 +668,10 @@ score_fetch_inst (struct gdbarch *gdbarch, CORE_ADDR addr, char *memblock)
}
}
- 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))
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index df2408c1ac2..b80a87126f6 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -520,9 +520,11 @@ sh_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr, int *lenptr)
#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;
@@ -536,7 +538,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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))
{
@@ -580,7 +582,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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);
}
}
}
@@ -594,7 +596,8 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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);
}
}
}
@@ -609,7 +612,8 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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)
@@ -648,7 +652,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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);
@@ -678,7 +682,7 @@ sh_analyze_prologue (CORE_ADDR pc, CORE_ADDR current_pc,
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;
@@ -741,7 +745,7 @@ sh_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
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;
@@ -1055,6 +1059,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
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;
@@ -1130,7 +1135,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
{
/* 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
@@ -1145,7 +1150,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
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);
}
@@ -1153,7 +1158,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
{
/* 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. */
@@ -1167,7 +1172,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch,
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. */
@@ -1194,6 +1199,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
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;
@@ -1253,7 +1259,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
{
/* 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
@@ -1269,7 +1275,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch,
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. */
@@ -1295,6 +1301,8 @@ static void
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;
@@ -1304,7 +1312,7 @@ sh_extract_return_value_nofpu (struct type *type, struct regcache *regcache,
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)
{
@@ -1345,12 +1353,14 @@ static void
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
@@ -2504,6 +2514,7 @@ sh_alloc_frame_cache (void)
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;
@@ -2529,7 +2540,7 @@ sh_frame_cache (struct frame_info *this_frame, void **this_cache)
{
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)
@@ -2542,8 +2553,7 @@ sh_frame_cache (struct frame_info *this_frame, void **this_cache)
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
@@ -2648,6 +2658,7 @@ static const struct frame_base sh_frame_base = {
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))
@@ -2665,7 +2676,7 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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;
@@ -2673,33 +2684,35 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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
@@ -2708,7 +2721,7 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
&& (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.
@@ -2716,7 +2729,8 @@ sh_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
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)
diff --git a/gdb/sh64-tdep.c b/gdb/sh64-tdep.c
index c6e5042664a..31228df3962 100644
--- a/gdb/sh64-tdep.c
+++ b/gdb/sh64-tdep.c
@@ -481,8 +481,10 @@ after_prologue (CORE_ADDR pc)
}
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);
@@ -491,7 +493,8 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
{
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))
{
@@ -500,7 +503,7 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
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;
@@ -515,7 +518,7 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
}
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))
@@ -524,7 +527,8 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
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;
@@ -557,11 +561,13 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
/* 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))
@@ -577,8 +583,9 @@ look_for_args_moves (CORE_ADDR start_pc, int media_mode)
}
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;
@@ -598,7 +605,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
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)
@@ -617,13 +625,14 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
/* 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)
@@ -643,7 +652,8 @@ sh64_skip_prologue_hard_way (CORE_ADDR start_pc)
/* 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;
}
}
@@ -667,7 +677,7 @@ sh64_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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? */
@@ -845,6 +855,7 @@ sh64_analyze_prologue (struct gdbarch *gdbarch,
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;
@@ -866,13 +877,14 @@ sh64_analyze_prologue (struct gdbarch *gdbarch,
{
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] =
@@ -1029,6 +1041,7 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -1109,7 +1122,8 @@ sh64_push_dummy_call (struct gdbarch *gdbarch,
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
@@ -1197,6 +1211,7 @@ sh64_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);
if (TYPE_CODE (type) == TYPE_CODE_FLT)
@@ -1587,6 +1602,7 @@ static void
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;
@@ -1726,17 +1742,17 @@ sh64_pseudo_register_read (struct gdbarch *gdbarch, struct regcache *regcache,
/* 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. */
}
@@ -1754,6 +1770,7 @@ static void
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];
@@ -1892,7 +1909,7 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
*/
/* *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;
@@ -1902,17 +1919,17 @@ sh64_pseudo_register_write (struct gdbarch *gdbarch, struct regcache *regcache,
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);
}
@@ -2321,6 +2338,7 @@ sh64_frame_prev_register (struct frame_info *this_frame,
{
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);
@@ -2339,7 +2357,8 @@ sh64_frame_prev_register (struct frame_info *this_frame,
&& (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);
}
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index 17f9547272c..97cc29c93db 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -79,6 +79,7 @@ static void
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;
@@ -97,11 +98,11 @@ darwin_load_image_infos (void)
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);
diff --git a/gdb/solib-frv.c b/gdb/solib-frv.c
index 080751d05c8..eec4e782661 100644
--- a/gdb/solib-frv.c
+++ b/gdb/solib-frv.c
@@ -97,6 +97,7 @@ struct int_elf32_fdpic_loadmap {
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;
@@ -113,7 +114,8 @@ fetch_loadmap (CORE_ADDR ldmaddr)
/* 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. */
@@ -122,7 +124,8 @@ fetch_loadmap (CORE_ADDR ldmaddr)
/* 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;
@@ -158,13 +161,16 @@ fetch_loadmap (CORE_ADDR ldmaddr)
{
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);
@@ -359,6 +365,7 @@ static CORE_ADDR main_lm_addr = 0;
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];
@@ -394,7 +401,7 @@ lm_base (void)
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,
@@ -427,6 +434,7 @@ lm_base (void)
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;
@@ -472,7 +480,8 @@ frv_current_sos (void)
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. */
@@ -486,7 +495,8 @@ frv_current_sos (void)
/* 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)
{
@@ -501,7 +511,8 @@ frv_current_sos (void)
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);
@@ -528,7 +539,8 @@ frv_current_sos (void)
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 ();
@@ -625,6 +637,7 @@ static int enable_break2_done = 0;
static int
enable_break2 (void)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (target_gdbarch);
int success = 0;
char **bkpt_namep;
asection *interp_sect;
@@ -756,7 +769,7 @@ enable_break2 (void)
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. */
@@ -768,7 +781,7 @@ enable_break2 (void)
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)
@@ -779,7 +792,7 @@ enable_break2 (void)
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);
@@ -1127,6 +1140,7 @@ find_canonical_descriptor_in_load_object
(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;
@@ -1219,18 +1233,20 @@ find_canonical_descriptor_in_load_object
/* 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. */
diff --git a/gdb/solib-irix.c b/gdb/solib-irix.c
index e60c520fa14..4cf8cc67cc8 100644
--- a/gdb/solib-irix.c
+++ b/gdb/solib-irix.c
@@ -130,9 +130,9 @@ union irix_obj_info
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
@@ -142,6 +142,7 @@ extract_mips_address (void *addr, int len)
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;
@@ -154,24 +155,27 @@ fetch_lm_info (CORE_ADDR addr)
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... */
@@ -183,19 +187,22 @@ fetch_lm_info (CORE_ADDR addr)
/* 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... */
@@ -207,16 +214,19 @@ fetch_lm_info (CORE_ADDR addr)
/* 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
{
@@ -494,6 +504,8 @@ irix_solib_create_inferior_hook (void)
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;
@@ -513,12 +525,8 @@ irix_current_sos (void)
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)
{
@@ -603,6 +611,8 @@ irix_current_sos (void)
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;
@@ -619,12 +629,8 @@ irix_open_symbol_file_object (void *from_ttyp)
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... */
diff --git a/gdb/solib-som.c b/gdb/solib-som.c
index 45080178c1b..457930c1f64 100644
--- a/gdb/solib-som.c
+++ b/gdb/solib-som.c
@@ -184,6 +184,7 @@ struct {
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;
@@ -222,7 +223,7 @@ som_solib_create_inferior_hook (void)
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)
{
@@ -265,7 +266,7 @@ GDB will be unable to track shl_load/shl_unload calls"));
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)
@@ -313,7 +314,7 @@ keep_going:
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
@@ -333,7 +334,7 @@ keep_going:
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."));
@@ -527,6 +528,7 @@ struct dld_list {
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];
@@ -537,7 +539,7 @@ link_map_start (void)
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."));
@@ -558,12 +560,12 @@ link_map_start (void)
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? */
@@ -576,6 +578,7 @@ match_main (const char *name)
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;
@@ -600,7 +603,7 @@ som_current_sos (void)
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."),
@@ -621,7 +624,8 @@ som_current_sos (void)
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);
@@ -636,7 +640,8 @@ som_current_sos (void)
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,
@@ -690,6 +695,7 @@ som_current_sos (void)
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;
@@ -709,7 +715,7 @@ som_open_symbol_file_object (void *from_ttyp)
/* 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. */
diff --git a/gdb/solib-sunos.c b/gdb/solib-sunos.c
index fd7089dc406..ff41847ac5b 100644
--- a/gdb/solib-sunos.c
+++ b/gdb/solib-sunos.c
@@ -120,7 +120,8 @@ static char *main_name_list[] =
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 */
@@ -140,33 +141,36 @@ static CORE_ADDR flag_addr;
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 */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 07e4f76a54a..0f175846a59 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -465,6 +465,7 @@ bfd_lookup_symbol (bfd *abfd, char *symname)
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;
@@ -501,7 +502,8 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
(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;
}
@@ -509,8 +511,10 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
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
{
@@ -524,7 +528,8 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
(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;
}
@@ -532,8 +537,10 @@ read_program_header (int type, int *p_sect_size, int *p_arch_size)
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. */
@@ -673,6 +680,7 @@ scan_dyntag (int dyntag, bfd *abfd, CORE_ADDR *ptr)
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;
@@ -693,14 +701,18 @@ scan_dyntag_auxv (int dyntag, CORE_ADDR *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;
@@ -870,13 +882,14 @@ solib_svr4_r_ldsomap (struct svr4_info *info)
{
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;
diff --git a/gdb/sparc-linux-tdep.c b/gdb/sparc-linux-tdep.c
index c462e1c4640..81badc689d4 100644
--- a/gdb/sparc-linux-tdep.c
+++ b/gdb/sparc-linux-tdep.c
@@ -139,6 +139,9 @@ sparc32_linux_step_trap (struct frame_info *frame, unsigned long insn)
/* __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);
@@ -158,7 +161,7 @@ sparc32_linux_step_trap (struct frame_info *frame, unsigned long insn)
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);
}
}
diff --git a/gdb/sparc-tdep.c b/gdb/sparc-tdep.c
index 04343d68a7b..bf711f0e6dd 100644
--- a/gdb/sparc-tdep.c
+++ b/gdb/sparc-tdep.c
@@ -152,8 +152,9 @@ sparc_is_unimp_insn (CORE_ADDR pc)
/* 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 = &current_target;
gdb_byte buf[8];
int len;
@@ -165,7 +166,7 @@ sparc_fetch_wcookie (void)
/* 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);
}
@@ -400,6 +401,8 @@ sparc32_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
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;
@@ -408,7 +411,8 @@ sparc32_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp,
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;
}
@@ -422,6 +426,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs,
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;
@@ -504,7 +509,7 @@ sparc32_store_arguments (struct regcache *regcache, int nargs,
{
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);
}
@@ -954,6 +959,7 @@ static struct value *
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);
@@ -974,7 +980,7 @@ sparc32_frame_prev_register (struct frame_info *this_frame,
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0 && !cache->frameless_p && regnum == SPARC_I7_REGNUM)
{
@@ -1133,6 +1139,8 @@ sparc32_return_value (struct gdbarch *gdbarch, struct type *func_type,
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
@@ -1149,7 +1157,7 @@ sparc32_return_value (struct gdbarch *gdbarch, struct type *func_type,
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));
}
@@ -1448,6 +1456,8 @@ sparc32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
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;
@@ -1466,10 +1476,12 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
/* 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);
@@ -1500,10 +1512,12 @@ sparc_supply_rwindow (struct regcache *regcache, CORE_ADDR sp, int regnum)
/* 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);
@@ -1516,6 +1530,8 @@ void
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;
@@ -1534,10 +1550,11 @@ sparc_collect_rwindow (const struct regcache *regcache,
/* 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);
@@ -1563,10 +1580,12 @@ sparc_collect_rwindow (const struct regcache *regcache,
/* 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),
diff --git a/gdb/sparc-tdep.h b/gdb/sparc-tdep.h
index 77a4578d9ed..6c8f50931de 100644
--- a/gdb/sparc-tdep.h
+++ b/gdb/sparc-tdep.h
@@ -157,7 +157,7 @@ struct sparc_frame_cache
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,
diff --git a/gdb/sparc64-linux-tdep.c b/gdb/sparc64-linux-tdep.c
index 2474575d0ea..965904ef82e 100644
--- a/gdb/sparc64-linux-tdep.c
+++ b/gdb/sparc64-linux-tdep.c
@@ -109,6 +109,9 @@ sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
{
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;
@@ -122,7 +125,8 @@ sparc64_linux_step_trap (struct frame_info *frame, unsigned long insn)
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;
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 47171a48e59..82baa178101 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -320,6 +320,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch,
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)
@@ -370,7 +371,7 @@ sparc64_pseudo_register_read (struct gdbarch *gdbarch,
state = (state >> 32) & ((1 << 8) - 1);
break;
}
- store_unsigned_integer (buf, 8, state);
+ store_unsigned_integer (buf, 8, byte_order, state);
}
}
@@ -379,6 +380,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch,
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)
@@ -414,7 +416,7 @@ sparc64_pseudo_register_write (struct gdbarch *gdbarch,
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:
@@ -486,6 +488,7 @@ static struct value *
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);
@@ -500,7 +503,7 @@ sparc64_frame_prev_register (struct frame_info *this_frame, void **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)
{
@@ -1166,7 +1169,9 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset,
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;
@@ -1178,10 +1183,10 @@ sparc64_supply_gregset (const struct sparc_gregset *gregset,
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);
}
@@ -1280,7 +1285,9 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset,
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;
@@ -1292,13 +1299,13 @@ sparc64_collect_gregset (const struct sparc_gregset *gregset,
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);
}
diff --git a/gdb/sparc64nbsd-tdep.c b/gdb/sparc64nbsd-tdep.c
index 9073abb1fd1..b3dbef0f983 100644
--- a/gdb/sparc64nbsd-tdep.c
+++ b/gdb/sparc64nbsd-tdep.c
@@ -92,6 +92,7 @@ struct trad_frame_saved_reg *
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;
@@ -134,7 +135,7 @@ sparc64nbsd_sigcontext_saved_regs (CORE_ADDR sigcontext_addr,
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0)
{
diff --git a/gdb/sparc64obsd-tdep.c b/gdb/sparc64obsd-tdep.c
index d58fa9985d4..c4407d22dfc 100644
--- a/gdb/sparc64obsd-tdep.c
+++ b/gdb/sparc64obsd-tdep.c
@@ -294,15 +294,17 @@ static void
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)
@@ -314,15 +316,15 @@ sparc64obsd_supply_uthread (struct regcache *regcache,
{
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);
}
@@ -337,6 +339,8 @@ static void
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];
@@ -355,15 +359,15 @@ sparc64obsd_collect_uthread(const struct regcache *regcache,
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);
}
diff --git a/gdb/sparcnbsd-tdep.c b/gdb/sparcnbsd-tdep.c
index 3af3102c411..723a98a281b 100644
--- a/gdb/sparcnbsd-tdep.c
+++ b/gdb/sparcnbsd-tdep.c
@@ -99,6 +99,7 @@ sparc32nbsd_pc_in_sigtramp (CORE_ADDR pc, char *name)
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;
@@ -147,7 +148,7 @@ sparc32nbsd_sigcontext_saved_regs (struct frame_info *this_frame)
/* Handle StackGhost. */
{
- ULONGEST wcookie = sparc_fetch_wcookie ();
+ ULONGEST wcookie = sparc_fetch_wcookie (gdbarch);
if (wcookie != 0)
{
diff --git a/gdb/sparcobsd-tdep.c b/gdb/sparcobsd-tdep.c
index 25b1ce5d61b..809b53a90fb 100644
--- a/gdb/sparcobsd-tdep.c
+++ b/gdb/sparcobsd-tdep.c
@@ -155,15 +155,17 @@ static void
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)
@@ -175,15 +177,15 @@ sparc32obsd_supply_uthread (struct regcache *regcache,
{
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);
}
@@ -198,6 +200,8 @@ static void
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];
@@ -216,15 +220,15 @@ sparc32obsd_collect_uthread(const struct regcache *regcache,
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);
}
diff --git a/gdb/spu-linux-nat.c b/gdb/spu-linux-nat.c
index f6a3c794ec7..f5a5fb10e57 100644
--- a/gdb/spu-linux-nat.c
+++ b/gdb/spu-linux-nat.c
@@ -204,6 +204,7 @@ store_ppc_memory (ULONGEST memaddr, const gdb_byte *myaddr, int len)
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 */
@@ -211,7 +212,7 @@ parse_spufs_run (int *fd, ULONGEST *addr)
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)
@@ -483,8 +484,10 @@ spu_fetch_inferior_registers (struct target_ops *ops,
/* 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);
}
diff --git a/gdb/spu-tdep.c b/gdb/spu-tdep.c
index 0034de49dac..e237ebfaafb 100644
--- a/gdb/spu-tdep.c
+++ b/gdb/spu-tdep.c
@@ -170,6 +170,8 @@ static void
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;
@@ -180,7 +182,7 @@ spu_pseudo_register_read_spu (struct regcache *regcache, const char *regname,
target_read (&current_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
@@ -229,6 +231,8 @@ 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;
@@ -236,7 +240,7 @@ spu_pseudo_register_write_spu (struct regcache *regcache, const char *regname,
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 (&current_target, TARGET_OBJECT_SPU, annex,
reg, 0, strlen (reg));
}
@@ -330,7 +334,9 @@ static CORE_ADDR
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)
@@ -530,9 +536,11 @@ struct spu_prologue_data
};
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;
@@ -592,7 +600,7 @@ spu_analyze_prologue (CORE_ADDR start_pc, CORE_ADDR end_pc,
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. */
@@ -706,7 +714,7 @@ static CORE_ADDR
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. */
@@ -715,7 +723,7 @@ spu_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR 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)
{
@@ -751,6 +759,7 @@ spu_virtual_frame_pointer (struct gdbarch *gdbarch, CORE_ADDR pc,
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;
@@ -780,7 +789,7 @@ spu_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
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))
{
@@ -808,7 +817,7 @@ spu_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
{
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;
@@ -841,6 +850,8 @@ static struct spu_unwind_cache *
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];
@@ -863,8 +874,8 @@ spu_frame_unwind_cache (struct frame_info *this_frame,
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)
@@ -874,7 +885,7 @@ spu_frame_unwind_cache (struct frame_info *this_frame,
/* 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++)
@@ -897,7 +908,7 @@ spu_frame_unwind_cache (struct frame_info *this_frame,
/* 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. */
@@ -933,12 +944,12 @@ spu_frame_unwind_cache (struct frame_info *this_frame,
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;
}
@@ -1126,6 +1137,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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;
@@ -1134,7 +1146,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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
@@ -1143,7 +1155,7 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
}
@@ -1207,11 +1219,11 @@ spu_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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);
@@ -1289,6 +1301,7 @@ static int
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;
@@ -1298,7 +1311,7 @@ spu_software_single_step (struct frame_info *frame)
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.
@@ -1319,7 +1332,7 @@ spu_software_single_step (struct frame_info *frame)
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);
@@ -1336,16 +1349,18 @@ spu_software_single_step (struct frame_info *frame)
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;
}
@@ -1401,6 +1416,8 @@ struct spu_overlay_table
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;
@@ -1436,10 +1453,14 @@ spu_get_overlay_table (struct objfile *objfile)
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;
@@ -1465,6 +1486,8 @@ spu_get_overlay_table (struct objfile *objfile)
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;
@@ -1476,7 +1499,7 @@ spu_overlay_update_osect (struct obj_section *osect)
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);
}
@@ -1595,6 +1618,8 @@ static void
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;
@@ -1607,7 +1632,7 @@ info_spu_signal_command (char *args, int from_tty)
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);
@@ -1618,7 +1643,7 @@ info_spu_signal_command (char *args, int from_tty)
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;
}
@@ -1636,7 +1661,7 @@ info_spu_signal_command (char *args, int from_tty)
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;
}
@@ -1686,7 +1711,7 @@ info_spu_signal_command (char *args, int from_tty)
}
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;
@@ -1705,7 +1730,7 @@ info_spu_mailbox_list (gdb_byte *buf, int nr,
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);
@@ -1720,13 +1745,15 @@ static void
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);
@@ -1739,7 +1766,8 @@ info_spu_mailbox_command (char *args, int from_tty)
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 (&current_target, TARGET_OBJECT_SPU, annex,
@@ -1747,7 +1775,8 @@ info_spu_mailbox_command (char *args, int from_tty)
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 (&current_target, TARGET_OBJECT_SPU, annex,
@@ -1755,7 +1784,8 @@ info_spu_mailbox_command (char *args, int from_tty)
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);
}
@@ -1768,7 +1798,7 @@ spu_mfc_get_bitfield (ULONGEST word, int first, int last)
}
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] =
{
@@ -1825,7 +1855,8 @@ info_spu_dma_cmdlist (gdb_byte *buf, int nr)
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;
@@ -1874,9 +1905,12 @@ info_spu_dma_cmdlist (gdb_byte *buf, int nr)
/* 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);
@@ -1947,6 +1981,8 @@ static void
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;
@@ -1969,11 +2005,16 @@ info_spu_dma_command (char *args, int from_tty)
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");
@@ -2013,7 +2054,7 @@ info_spu_dma_command (char *args, int from_tty)
printf_filtered ("\n");
}
- info_spu_dma_cmdlist (buf + 40, 16);
+ info_spu_dma_cmdlist (buf + 40, 16, byte_order);
do_cleanups (chain);
}
@@ -2021,6 +2062,8 @@ static void
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;
@@ -2030,7 +2073,7 @@ info_spu_proxydma_command (char *args, int from_tty)
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);
@@ -2041,9 +2084,9 @@ info_spu_proxydma_command (char *args, int from_tty)
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");
@@ -2075,7 +2118,7 @@ info_spu_proxydma_command (char *args, int from_tty)
printf_filtered ("\n");
}
- info_spu_dma_cmdlist (buf + 24, 8);
+ info_spu_dma_cmdlist (buf + 24, 8, byte_order);
do_cleanups (chain);
}
diff --git a/gdb/stack.c b/gdb/stack.c
index 757e1097326..3eea0a1b181 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -164,6 +164,8 @@ static void
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;
@@ -174,7 +176,8 @@ print_frame_nameless_args (struct frame_info *frame, long start, int num,
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);
@@ -1184,6 +1187,8 @@ frame_info (char *addr_exp, int from_tty)
&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),
@@ -1192,9 +1197,7 @@ frame_info (char *addr_exp, int from_tty)
/* 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");
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 20ae85f2390..4dd9c1ce4e4 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -129,7 +129,8 @@ static void overlay_command (char *, int);
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);
@@ -3750,7 +3751,7 @@ simple_free_overlay_region_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);
@@ -3758,7 +3759,7 @@ read_target_long_array (CORE_ADDR memaddr, unsigned int *myaddr,
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
@@ -3769,6 +3770,7 @@ simple_read_overlay_table (void)
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);
@@ -3791,14 +3793,16 @@ simple_read_overlay_table (void)
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 */
}
@@ -3810,25 +3814,33 @@ static int
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 */
@@ -3855,6 +3867,7 @@ simple_overlay_update_1 (struct obj_section *osect)
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++)
@@ -3864,7 +3877,7 @@ simple_overlay_update_1 (struct obj_section *osect)
{
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 */ )
diff --git a/gdb/target.c b/gdb/target.c
index e821d4b87d6..e1c1e0b66c9 100644
--- a/gdb/target.c
+++ b/gdb/target.c
@@ -1832,13 +1832,13 @@ get_target_memory (struct target_ops *ops, CORE_ADDR addr, gdb_byte *buf,
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
@@ -2796,6 +2796,7 @@ debug_print_register (const char * func,
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);
@@ -2806,7 +2807,7 @@ debug_print_register (const char * func,
}
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));
}
diff --git a/gdb/target.h b/gdb/target.h
index 94750bbd9c3..24c803c30af 100644
--- a/gdb/target.h
+++ b/gdb/target.h
@@ -305,7 +305,8 @@ extern char *target_read_stralloc (struct target_ops *ops,
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);
struct thread_info; /* fwd decl for parameter list below: */
diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c
index 46d32fd0bed..d1eb9d535ce 100644
--- a/gdb/tramp-frame.c
+++ b/gdb/tramp-frame.c
@@ -81,6 +81,8 @@ static CORE_ADDR
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. */
@@ -98,7 +100,7 @@ tramp_frame_start (const struct tramp_frame *tramp,
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;
}
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index daff7e1bdd4..325466a6787 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -453,9 +453,11 @@ v850_is_save_register (int reg)
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;
@@ -488,11 +490,11 @@ v850_analyze_prologue (CORE_ADDR func_addr, CORE_ADDR pc,
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;
}
@@ -520,7 +522,8 @@ v850_analyze_prologue (CORE_ADDR func_addr, CORE_ADDR pc,
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 */
@@ -671,6 +674,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
int struct_return,
CORE_ADDR struct_addr)
{
+ enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
int argreg;
int argnum;
int len = 0;
@@ -705,7 +709,8 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
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;
}
@@ -720,7 +725,7 @@ v850_push_dummy_call (struct gdbarch *gdbarch,
{
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;
@@ -751,6 +756,8 @@ static void
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)
@@ -758,7 +765,7 @@ v850_extract_return_value (struct type *type, struct regcache *regcache,
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)
{
@@ -776,11 +783,14 @@ static void
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;
@@ -834,6 +844,7 @@ v850_alloc_frame_cache (struct frame_info *this_frame)
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;
@@ -859,7 +870,7 @@ v850_frame_cache (struct frame_info *this_frame, void **this_cache)
{
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)
diff --git a/gdb/valarith.c b/gdb/valarith.c
index 975a49ee5fa..a9c875d907a 100644
--- a/gdb/valarith.c
+++ b/gdb/valarith.c
@@ -773,7 +773,8 @@ uinteger_pow (ULONGEST v1, LONGEST v2)
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;
@@ -796,13 +797,15 @@ value_args_as_decimal (struct value *arg1, struct value *arg2,
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),
@@ -813,13 +816,15 @@ value_args_as_decimal (struct value *arg1, struct value *arg2,
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),
@@ -857,6 +862,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
{
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];
@@ -872,8 +878,10 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
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)
{
@@ -882,7 +890,9 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode 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:
@@ -990,6 +1000,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
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
@@ -1124,6 +1135,8 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
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
@@ -1235,6 +1248,8 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op)
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);
}
}
@@ -1257,7 +1272,8 @@ value_logical_not (struct value *arg1)
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);
@@ -1341,10 +1357,13 @@ value_equal (struct value *arg1, struct value *arg2)
{
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
@@ -1415,10 +1434,13 @@ value_less (struct value *arg1, struct value *arg2)
{
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);
@@ -1531,7 +1553,8 @@ value_bit_index (struct type *type, const gdb_byte *valaddr, int index)
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;
diff --git a/gdb/valops.c b/gdb/valops.c
index a9260cedb53..2d20b4153a1 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -422,17 +422,18 @@ value_cast (struct type *type, struct value *arg2)
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);
}
@@ -450,8 +451,9 @@ value_cast (struct type *type, struct value *arg2)
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 ?
@@ -541,8 +543,9 @@ value_one (struct type *type, enum lval_type lv)
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)
diff --git a/gdb/valprint.c b/gdb/valprint.c
index c7efef0bc68..cbb5d94a9e7 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -409,7 +409,7 @@ val_print_type_code_int (struct type *type, const gdb_byte *valaddr,
if (TYPE_UNSIGNED (type)
&& extract_long_unsigned_integer (valaddr, TYPE_LENGTH (type),
- &val))
+ byte_order, &val))
{
print_longest (stream, 'u', 0, val);
}
@@ -605,10 +605,11 @@ void
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;
}
@@ -1268,7 +1269,7 @@ partial_memory_read (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int *errnoptr
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. */
@@ -1340,7 +1341,7 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
{
unsigned long c;
- c = extract_unsigned_integer (bufptr, width);
+ c = extract_unsigned_integer (bufptr, width, byte_order);
addr += width;
bufptr += width;
if (c == 0)
@@ -1394,6 +1395,7 @@ val_print_string (struct type *elttype, CORE_ADDR addr, int len,
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
@@ -1406,7 +1408,8 @@ val_print_string (struct type *elttype, CORE_ADDR addr, int len,
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;
@@ -1415,8 +1418,8 @@ val_print_string (struct type *elttype, CORE_ADDR addr, int len,
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;
@@ -1428,7 +1431,7 @@ val_print_string (struct type *elttype, CORE_ADDR addr, int len,
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))
diff --git a/gdb/valprint.h b/gdb/valprint.h
index 4f63fa649a8..c0be1162f99 100644
--- a/gdb/valprint.h
+++ b/gdb/valprint.h
@@ -144,6 +144,7 @@ extern void print_char_chars (struct ui_file *, struct type *,
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
diff --git a/gdb/value.c b/gdb/value.c
index dc2e8bc3093..fffc183af07 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -1626,6 +1626,7 @@ value_as_address (struct value *val)
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);
@@ -1642,9 +1643,9 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
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);
@@ -1652,7 +1653,7 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
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:
@@ -1675,6 +1676,7 @@ unpack_long (struct type *type, const gdb_byte *valaddr)
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;
@@ -1712,7 +1714,7 @@ unpack_double (struct type *type, const gdb_byte *valaddr, int *invp)
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. */
@@ -1980,6 +1982,7 @@ value_fn_field (struct value **arg1p, struct fn_field *f, int j, struct type *ty
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);
@@ -1987,7 +1990,8 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int 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);
@@ -2028,6 +2032,7 @@ void
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);
@@ -2047,7 +2052,7 @@ modify_field (struct type *type, gdb_byte *addr,
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)))
@@ -2056,7 +2061,7 @@ modify_field (struct type *type, gdb_byte *addr,
oword &= ~(mask << bitpos);
oword |= fieldval << bitpos;
- store_unsigned_integer (addr, sizeof oword, oword);
+ store_unsigned_integer (addr, sizeof oword, byte_order, oword);
}
/* Pack NUM into BUF using a target format of TYPE. */
@@ -2064,6 +2069,7 @@ modify_field (struct type *type, gdb_byte *addr,
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);
@@ -2078,7 +2084,7 @@ pack_long (gdb_byte *buf, struct type *type, LONGEST num)
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:
diff --git a/gdb/vax-tdep.c b/gdb/vax-tdep.c
index a68f6cdfa54..f42a3981d96 100644
--- a/gdb/vax-tdep.c
+++ b/gdb/vax-tdep.c
@@ -113,6 +113,8 @@ static CORE_ADDR
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;
@@ -132,11 +134,11 @@ vax_store_arguments (struct regcache *regcache, int nargs,
/* 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;
@@ -148,6 +150,7 @@ vax_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
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];
@@ -160,12 +163,12 @@ vax_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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. */
@@ -173,16 +176,16 @@ vax_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
/* 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);
@@ -269,26 +272,27 @@ vax_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pc, int *len)
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;
diff --git a/gdb/xstormy16-tdep.c b/gdb/xstormy16-tdep.c
index c5601b437b9..d5d3689ad2b 100644
--- a/gdb/xstormy16-tdep.c
+++ b/gdb/xstormy16-tdep.c
@@ -233,6 +233,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -266,7 +267,8 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
extract_unsigned_integer (val + j,
typelen - j ==
1 ? 1 :
- xstormy16_reg_size));
+ xstormy16_reg_size,
+ byte_order));
}
/* Align SP */
@@ -289,7 +291,7 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -309,10 +311,12 @@ xstormy16_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -328,9 +332,10 @@ xstormy16_analyze_prologue (CORE_ADDR start_addr, CORE_ADDR end_addr,
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 */
{
@@ -419,7 +424,8 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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;
@@ -450,6 +456,7 @@ xstormy16_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR pc)
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))
@@ -463,19 +470,21 @@ xstormy16_in_function_epilogue_p (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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;
@@ -501,8 +510,9 @@ xstormy16_breakpoint_from_pc (struct gdbarch *gdbarch, CORE_ADDR *pcptr,
/* 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)
@@ -516,9 +526,10 @@ xstormy16_resolve_jmp_table_entry (CORE_ADDR faddr)
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;
}
@@ -530,8 +541,9 @@ xstormy16_resolve_jmp_table_entry (CORE_ADDR faddr)
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)
@@ -562,9 +574,10 @@ xstormy16_find_jmp_table_entry (CORE_ADDR faddr)
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;
@@ -577,7 +590,8 @@ xstormy16_find_jmp_table_entry (CORE_ADDR faddr)
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;
@@ -595,12 +609,14 @@ static CORE_ADDR
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;
}
@@ -612,15 +628,16 @@ static void
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 *
@@ -645,6 +662,7 @@ xstormy16_alloc_frame_cache (void)
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;
@@ -662,7 +680,8 @@ xstormy16_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index e81b87e850d..ff683faaf0e 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -165,6 +165,7 @@ windowing_enabled (CORE_ADDR ps)
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];
@@ -173,7 +174,7 @@ extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
/* 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
@@ -183,7 +184,7 @@ extract_call_winsize (struct gdbarch *gdbarch, CORE_ADDR pc)
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. */
@@ -502,6 +503,8 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch,
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));
@@ -518,7 +521,7 @@ xtensa_pseudo_register_read (struct gdbarch *gdbarch,
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. */
@@ -598,6 +601,8 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
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));
@@ -616,7 +621,7 @@ xtensa_pseudo_register_write (struct gdbarch *gdbarch,
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.
@@ -1173,6 +1178,7 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
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;
@@ -1197,7 +1203,7 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
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);
@@ -1258,8 +1264,8 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
/* 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)
@@ -1279,7 +1285,7 @@ xtensa_frame_cache (struct frame_info *this_frame, void **this_cache)
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
{
@@ -1591,6 +1597,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
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);
@@ -1734,7 +1741,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
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);
}
@@ -1770,13 +1777,13 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
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;
@@ -1803,7 +1810,7 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
{
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,
@@ -1816,9 +1823,9 @@ xtensa_push_dummy_call (struct gdbarch *gdbarch,
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
{
@@ -1970,10 +1977,12 @@ call0_classify_opcode (xtensa_isa isa, xtensa_opcode opc)
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)
@@ -2027,7 +2036,7 @@ call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
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;
@@ -2080,7 +2089,8 @@ call0_track_op (xtensa_c0reg_t dst[], xtensa_c0reg_t src[],
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. */
@@ -2271,7 +2281,8 @@ call0_analyze_prologue (CORE_ADDR start, CORE_ADDR pc, CORE_ADDR litbase,
}
/* 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:
@@ -2289,6 +2300,7 @@ call0_frame_cache (struct frame_info *this_frame,
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;
@@ -2299,7 +2311,8 @@ call0_frame_cache (struct frame_info *this_frame,
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);
}
@@ -2354,7 +2367,8 @@ call0_frame_cache (struct frame_info *this_frame,
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)
@@ -2473,7 +2487,7 @@ xtensa_skip_prologue (struct gdbarch *gdbarch, CORE_ADDR start_pc)
}
/* 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;
}