21#include "gdbsupport/x86-xstate.h"
29#include "coff/internal.h"
108#define AMD64_WINDOWS_SIZEOF_GREGSET 1232
121 case TYPE_CODE_RANGE:
125 case TYPE_CODE_RVALUE_REF:
126 case TYPE_CODE_STRUCT:
127 case TYPE_CODE_UNION:
128 case TYPE_CODE_COMPLEX:
145 return ((
type->
code () == TYPE_CODE_FLT
146 ||
type->
code () == TYPE_CODE_DECFLOAT)
174 int nargs, CORE_ADDR sp)
178 for (i = 0; i < nargs; i++)
181 struct type *
type = args[i]->type ();
182 const gdb_byte *valbuf = args[i]->contents ().data ();
205 struct value *arg,
int regno)
208 const gdb_byte *valbuf = arg->
contents ().data ();
212 memset (buf, 0,
sizeof buf);
213 memcpy (buf, valbuf, std::min (
type->
length (), (ULONGEST) 8));
225 struct value **args, CORE_ADDR sp,
230 struct value **stack_args = XALLOCAVEC (
struct value *, nargs);
231 int num_stack_args = 0;
232 int num_elements = 0;
241 struct value **args1 = XALLOCAVEC (
struct value *, nargs);
243 memcpy (args1, args, nargs *
sizeof (
struct value *));
252 for (i = 0; i < nargs; i++)
254 struct type *
type = args[i]->type ();
284 num_elements += ((len + 7) / 8);
285 stack_args[num_stack_args++] = args[i];
291 sp -= num_elements * 8;
295 for (i = 0; i < num_stack_args; i++)
298 const gdb_byte *valbuf = stack_args[i]->
contents ().data ();
313 int nargs,
struct value **args, CORE_ADDR sp,
358 struct value **read_value,
const gdb_byte *writebuf)
369 if (len == 4 || len == 8)
372 case TYPE_CODE_ARRAY:
377 if (
code == TYPE_CODE_INT ||
code == TYPE_CODE_FLT)
387 if (len == 1 || len == 2 || len == 4 || len == 8)
389 else if (len == 16 &&
type->
code () == TYPE_CODE_INT)
397 if (read_value !=
nullptr)
409 if (read_value !=
nullptr)
413 (*read_value)->contents_raw ().data ());
511 && pc < cache->image_base + cache->
end_rva);
537 CORE_ADDR pc = cache->
pc;
538 CORE_ADDR cur_sp = cache->
sp;
557 if (op >= 0x40 && op <= 0x4f)
569 if (op >= 0x58 && op <= 0x5f)
572 gdb_byte reg = (op & 0x0f) | ((rex & 1) << 3);
608 npc = pc + 2 + (
signed char) rel8;
686 return (op1 & 0xf8) == 0xe0;
702 CORE_ADDR unwind_info)
704 CORE_ADDR save_addr = 0;
705 CORE_ADDR cur_sp = cache->
sp;
733 struct external_pex64_runtime_function d;
736 (gdb_byte *) &d, sizeof (d)) != 0)
749 struct external_pex64_unwind_info ex_ui;
751 gdb_byte insns[2 * 256];
754 unsigned char codes_count;
755 unsigned char frame_reg;
760 (gdb_byte *) &ex_ui, sizeof (ex_ui)) != 0)
765 ex_ui.Version_Flags, ex_ui.SizeOfPrologue,
766 ex_ui.CountOfCodes, ex_ui.FrameRegisterOffset);
769 if (PEX64_UWI_VERSION (ex_ui.Version_Flags) != 1
770 && PEX64_UWI_VERSION (ex_ui.Version_Flags) != 2)
775 && !(cache->
pc >= start && cache->
pc < start + ex_ui.SizeOfPrologue))
790 codes_count = ex_ui.CountOfCodes;
791 frame_reg = PEX64_UWI_FRAMEREG (ex_ui.FrameRegisterOffset);
813 insns, codes_count * 2) != 0)
816 end_insns = &insns[codes_count * 2];
820 if (PEX64_UWI_VERSION (ex_ui.Version_Flags) == 2)
822 for (; p < end_insns; p += 2)
823 if (PEX64_UNWCODE_CODE (p[1]) != 6)
827 for (; p < end_insns; p += 2)
835 if (cache->
pc >= start + p[0] || cache->
pc < start)
838 (
unsigned) (p - insns), p[0], p[1]);
847 switch (PEX64_UNWCODE_CODE (p[1]))
849 case UWOP_PUSH_NONVOL:
855 case UWOP_ALLOC_LARGE:
856 if (PEX64_UNWCODE_INFO (p[1]) == 0)
859 else if (PEX64_UNWCODE_INFO (p[1]) == 1)
864 case UWOP_ALLOC_SMALL:
865 cur_sp += 8 + 8 * PEX64_UNWCODE_INFO (p[1]);
869 - PEX64_UWI_FRAMEOFF (ex_ui.FrameRegisterOffset) * 16;
871 case UWOP_SAVE_NONVOL:
876 case UWOP_SAVE_NONVOL_FAR:
881 case UWOP_SAVE_XMM128:
886 case UWOP_SAVE_XMM128_FAR:
891 case UWOP_PUSH_MACHFRAME:
892 if (PEX64_UNWCODE_INFO (p[1]) == 0)
898 else if (PEX64_UNWCODE_INFO (p[1]) == 1)
920 switch (PEX64_UNWCODE_CODE (p[1]))
922 case UWOP_PUSH_NONVOL:
923 case UWOP_ALLOC_SMALL:
925 case UWOP_PUSH_MACHFRAME:
927 case UWOP_ALLOC_LARGE:
928 if (PEX64_UNWCODE_INFO (p[1]) == 0)
930 else if (PEX64_UNWCODE_INFO (p[1]) == 1)
935 case UWOP_SAVE_NONVOL:
936 case UWOP_SAVE_XMM128:
939 case UWOP_SAVE_NONVOL_FAR:
940 case UWOP_SAVE_XMM128_FAR:
947 if (PEX64_UWI_FLAGS (ex_ui.Version_Flags) != UNW_FLAG_CHAININFO)
955 struct external_pex64_runtime_function d;
963 +
sizeof (ex_ui) + ((codes_count + 1) & ~1) * 2;
1006 CORE_ADDR *unwind_info,
1007 CORE_ADDR *image_base,
1008 CORE_ADDR *start_rva,
1013 IMAGE_DATA_DIRECTORY *dir;
1015 unsigned long lo, hi;
1025 dir = &pe->pe_opthdr.DataDirectory[PE_EXCEPTION_TABLE];
1038 hi = dir->Size /
sizeof (
struct external_pex64_runtime_function);
1042 unsigned long mid = lo + (hi - lo) / 2;
1043 struct external_pex64_runtime_function d;
1047 (gdb_byte *) &d,
sizeof (d)) != 0)
1054 else if (pc >= base + ea)
1056 else if (pc >= base + sa && pc < base + ea)
1087 CORE_ADDR unwind_info = 0;
1093 *this_cache = cache;
1108 || unwind_info == 0)
1125static struct value *
1127 void **this_cache,
int regnum)
1200 CORE_ADDR func_addr;
1201 CORE_ADDR unwind_info = 0;
1202 CORE_ADDR image_base, start_rva, end_rva;
1203 struct external_pex64_unwind_info ex_ui;
1207 &image_base, &start_rva, &end_rva) == 0)
1209 if (unwind_info == 0)
1215 (gdb_byte *) &ex_ui,
sizeof (ex_ui)) == 0
1216 && PEX64_UWI_VERSION (ex_ui.Version_Flags) == 1)
1217 return std::max (pc, image_base + start_rva + ex_ui.SizeOfPrologue);
1225 CORE_ADDR post_prologue_pc
1228 if (post_prologue_pc != 0)
1229 return std::max (pc, post_prologue_pc);
1240 CORE_ADDR destination = 0;
1252 CORE_ADDR indirect_addr = pc + offset + 6;
1258 const char *symname = indsym ? indsym->
linkage_name () : NULL;
1262 if (startswith (symname,
"__imp_")
1263 || startswith (symname,
"_imp_"))
1369 asection *section = bfd_get_section_by_name (abfd,
".reg");
1370 if (section !=
nullptr
const struct target_desc * amd64_target_description(uint64_t xcr0, bool segments)
void amd64_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch, const target_desc *default_tdesc)
static enum return_value_convention amd64_windows_return_value(struct gdbarch *gdbarch, struct value *function, struct type *type, struct regcache *regcache, struct value **read_value, const gdb_byte *writebuf)
#define AMD64_WINDOWS_SIZEOF_GREGSET
void _initialize_amd64_windows_tdep()
static int pc_in_range(CORE_ADDR pc, const struct amd64_windows_frame_cache *cache)
static int amd64_windows_frame_decode_epilogue(frame_info_ptr this_frame, struct amd64_windows_frame_cache *cache)
static enum amd64_regnum amd64_windows_w2gdb_regnum[]
static CORE_ADDR amd64_windows_adjust_args_passed_by_pointer(struct value **args, int nargs, CORE_ADDR sp)
static void amd64_windows_frame_decode_insns(frame_info_ptr this_frame, struct amd64_windows_frame_cache *cache, CORE_ADDR unwind_info)
static CORE_ADDR amd64_windows_push_arguments(struct regcache *regcache, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method)
static const char * amd64_windows_auto_wide_charset(void)
static int amd64_windows_passed_by_pointer(struct type *type)
static int amd64_windows_find_unwind_info(struct gdbarch *gdbarch, CORE_ADDR pc, CORE_ADDR *unwind_info, CORE_ADDR *image_base, CORE_ADDR *start_rva, CORE_ADDR *end_rva)
static CORE_ADDR amd64_skip_main_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static struct value * amd64_windows_frame_prev_register(frame_info_ptr this_frame, void **this_cache, int regnum)
static int amd64_windows_gregset_reg_offset[]
static struct amd64_windows_frame_cache * amd64_windows_frame_cache(frame_info_ptr this_frame, void **this_cache)
static CORE_ADDR amd64_windows_skip_trampoline_code(frame_info_ptr frame, CORE_ADDR pc)
static int amd64_windows_dummy_call_integer_regs[]
static CORE_ADDR amd64_windows_push_dummy_call(struct gdbarch *gdbarch, struct value *function, struct regcache *regcache, CORE_ADDR bp_addr, int nargs, struct value **args, CORE_ADDR sp, function_call_return_method return_method, CORE_ADDR struct_addr)
static CORE_ADDR amd64_windows_skip_prologue(struct gdbarch *gdbarch, CORE_ADDR pc)
static void amd64_windows_store_arg_in_reg(struct regcache *regcache, struct value *arg, int regno)
static int amd64_windows_passed_by_integer_register(struct type *type)
static int amd64_windows_passed_by_xmm_register(struct type *type)
static void amd64_windows_init_abi_common(gdbarch_info info, struct gdbarch *gdbarch)
static gdb_osabi amd64_windows_osabi_sniffer(bfd *abfd)
static const struct frame_unwind amd64_windows_frame_unwind
static void amd64_cygwin_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void amd64_windows_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static void amd64_windows_frame_this_id(frame_info_ptr this_frame, void **this_cache, struct frame_id *this_id)
static enum gdb_osabi amd64_cygwin_core_osabi_sniffer(bfd *abfd)
bool find_pc_partial_function(CORE_ADDR pc, const char **name, CORE_ADDR *address, CORE_ADDR *endaddr, const struct block **block)
enum register_status raw_read_part(int regnum, int offset, int len, gdb_byte *buf)
void cooked_write(int regnum, const gdb_byte *buf)
void raw_write_part(int regnum, int offset, int len, const gdb_byte *buf)
void write_memory(CORE_ADDR memaddr, const bfd_byte *myaddr, ssize_t len)
ULONGEST read_memory_unsigned_integer(CORE_ADDR memaddr, int len, enum bfd_endian byte_order)
static void store_unsigned_integer(gdb_byte *addr, int len, enum bfd_endian byte_order, ULONGEST val)
static LONGEST extract_signed_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
@ RETURN_VALUE_ABI_RETURNS_ADDRESS
@ RETURN_VALUE_REGISTER_CONVENTION
int default_frame_sniffer(const struct frame_unwind *self, frame_info_ptr this_frame, void **this_prologue_cache)
struct value * frame_unwind_got_memory(frame_info_ptr frame, int regnum, CORE_ADDR addr)
struct value * frame_unwind_got_register(frame_info_ptr frame, int regnum, int new_regnum)
enum unwind_stop_reason default_frame_unwind_stop_reason(frame_info_ptr this_frame, void **this_cache)
struct value * frame_unwind_got_constant(frame_info_ptr frame, int regnum, ULONGEST val)
void frame_unwind_append_unwinder(struct gdbarch *gdbarch, const struct frame_unwind *unwinder)
CORE_ADDR get_frame_pc(frame_info_ptr frame)
void get_frame_register(frame_info_ptr frame, int regnum, gdb_byte *buf)
struct frame_id frame_id_build(CORE_ADDR stack_addr, CORE_ADDR code_addr)
struct gdbarch * get_frame_arch(frame_info_ptr this_frame)
#define frame_debug_printf(fmt,...)
#define FRAME_OBSTACK_ZALLOC(TYPE)
void set_gdbarch_auto_wide_charset(struct gdbarch *gdbarch, gdbarch_auto_wide_charset_ftype *auto_wide_charset)
void set_gdbarch_return_value_as_value(struct gdbarch *gdbarch, gdbarch_return_value_as_value_ftype *return_value_as_value)
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
const char * gdbarch_register_name(struct gdbarch *gdbarch, int regnr)
void set_gdbarch_skip_prologue(struct gdbarch *gdbarch, gdbarch_skip_prologue_ftype *skip_prologue)
void set_gdbarch_skip_trampoline_code(struct gdbarch *gdbarch, gdbarch_skip_trampoline_code_ftype *skip_trampoline_code)
void set_gdbarch_skip_main_prologue(struct gdbarch *gdbarch, gdbarch_skip_main_prologue_ftype *skip_main_prologue)
void set_gdbarch_core_pid_to_str(struct gdbarch *gdbarch, gdbarch_core_pid_to_str_ftype *core_pid_to_str)
void set_gdbarch_long_bit(struct gdbarch *gdbarch, int long_bit)
void set_gdbarch_core_xfer_shared_libraries(struct gdbarch *gdbarch, gdbarch_core_xfer_shared_libraries_ftype *core_xfer_shared_libraries)
void set_gdbarch_push_dummy_call(struct gdbarch *gdbarch, gdbarch_push_dummy_call_ftype *push_dummy_call)
function_call_return_method
struct bound_minimal_symbol lookup_minimal_symbol_by_pc(CORE_ADDR pc)
struct obj_section * find_pc_section(CORE_ADDR pc)
void gdbarch_register_osabi(enum bfd_architecture arch, unsigned long machine, enum gdb_osabi osabi, void(*init_osabi)(struct gdbarch_info, struct gdbarch *))
void gdbarch_register_osabi_sniffer(enum bfd_architecture arch, enum bfd_flavour flavour, enum gdb_osabi(*sniffer_fn)(bfd *))
enum register_status regcache_raw_read_unsigned(struct regcache *regcache, int regnum, ULONGEST *val)
CORE_ADDR prev_xmm_addr[16]
CORE_ADDR prev_reg_addr[16]
struct minimal_symbol * minsym
const char * linkage_name() const
objfile(gdb_bfd_ref_ptr, const char *, objfile_flags)
CORE_ADDR text_section_offset() const
struct type * target_type() const
static struct value * allocate(struct type *type)
gdb::array_view< const gdb_byte > contents()
struct type * type() const
CORE_ADDR skip_prologue_using_sal(struct gdbarch *gdbarch, CORE_ADDR func_addr)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
struct value * value_at_non_lval(struct type *type, CORE_ADDR addr)
struct value * value_addr(struct value *arg1)
struct value * value_from_contents_and_address(struct type *type, const gdb_byte *valaddr, CORE_ADDR address, frame_info_ptr frame)
std::string windows_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
bool is_linked_with_cygwin_dll(bfd *abfd)
ULONGEST windows_core_xfer_shared_libraries(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
void cygwin_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
void windows_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)