20#include "gdbsupport/gdb_obstack.h"
36#include "coff/internal.h"
40#define CYGWIN_DLL_NAME "cygwin1.dll"
155 " current_top_of_stack ",
156 " current_bottom_of_stack ",
159 " arbitrary_data_slot ",
160 " linear_address_tib ",
161 " environment_pointer ",
163 " current_thread_id ",
164 " active_rpc_handle ",
165 " thread_local_storage ",
166 " process_environment_block ",
167 " last_error_number "
194 if (result ==
nullptr)
204 struct type *dword_ptr_type, *dword32_type, *void_ptr_type;
205 struct type *peb_ldr_type, *peb_ldr_ptr_type;
206 struct type *peb_type, *peb_ptr_type, *list_type;
207 struct type *module_list_ptr_type;
208 struct type *tib_type, *seh_type, *tib_ptr_type, *seh_ptr_type;
209 struct type *word_type, *wchar_type, *wchar_ptr_type;
210 struct type *uni_str_type, *rupp_type, *rupp_ptr_type;
229 nullptr, wchar_type);
234 list_type->
set_name (xstrdup (
"list"));
236 module_list_ptr_type = void_ptr_type;
239 module_list_ptr_type);
241 module_list_ptr_type);
246 seh_type->
set_name (xstrdup (
"seh"));
248 seh_ptr_type = alloc.
new_type (TYPE_CODE_PTR,
249 void_ptr_type->
length () * TARGET_CHAR_BIT,
259 peb_ldr_type->
set_name (xstrdup (
"peb_ldr_data"));
269 peb_ldr_ptr_type = alloc.
new_type (TYPE_CODE_PTR,
270 void_ptr_type->
length () * TARGET_CHAR_BIT,
282 wchar_ptr_type->
length ());
296 void_ptr_type->
length ());
317 void_ptr_type->
length ());
328 peb_type->
set_name (xstrdup (
"peb"));
339 peb_ptr_type = alloc.
new_type (TYPE_CODE_PTR,
340 void_ptr_type->
length () * TARGET_CHAR_BIT,
347 tib_type->
set_name (xstrdup (
"tib"));
383 tib_ptr_type = alloc.
new_type (TYPE_CODE_PTR,
384 void_ptr_type->
length () * TARGET_CHAR_BIT,
408 error (_(
"Unable to read tlb"));
418 error (_(
"Impossible to change the Thread Local Base"));
450 gdb_byte *tib = NULL;
452 CORE_ADDR thread_local_base;
453 ULONGEST i, val, max, max_name,
size, tib_size;
457 if (sizeof_ptr == 64)
459 size =
sizeof (uint64_t);
465 size =
sizeof (uint32_t);
475 max = tib_size /
size;
478 tib = (gdb_byte *) alloca (tib_size);
482 gdb_printf (_(
"Unable to get thread local base for %s\n"),
488 NULL, tib, thread_local_base, tib_size) != tib_size)
490 gdb_printf (_(
"Unable to read thread information "
491 "block for %s at address %s\n"),
497 gdb_printf (_(
"Thread Information Block %s at %s\n"),
501 index = (gdb_byte *) tib;
505 for (i = 0; i < max; i++)
529 CORE_ADDR *text_offset_cached,
532 CORE_ADDR text_offset = text_offset_cached ? *text_offset_cached : 0;
534 obstack_grow_str (obstack,
"<library name=\"");
535 std::string p = xml_escape_text (so_name);
536 obstack_grow_str (obstack, p.c_str ());
537 obstack_grow_str (obstack,
"\"><segment address=\"");
546 if (text_offset_cached)
547 *text_offset_cached = text_offset;
550 obstack_grow_str (obstack,
paddress (
gdbarch, load_addr + text_offset));
551 obstack_grow_str (obstack,
"\"/></library>");
579 if (cb (current_objfile))
584 if (
objfile != current_objfile)
595 gdb_printf (file, _(
"Show all non-zero elements of "
596 "Thread Information Block is %s.\n"),
value);
608 _(
"Print information specific to Win32 debugging."),
627 case GDB_SIGNAL_QUIT:
631 case GDB_SIGNAL_TRAP:
633 case GDB_SIGNAL_ABRT:
639 case GDB_SIGNAL_KILL:
643 case GDB_SIGNAL_SEGV:
647 case GDB_SIGNAL_PIPE:
649 case GDB_SIGNAL_ALRM:
651 case GDB_SIGNAL_TERM:
670 case GDB_SIGNAL_QUIT:
674 case GDB_SIGNAL_TRAP:
676 case GDB_SIGNAL_ABRT:
682 case GDB_SIGNAL_KILL:
686 case GDB_SIGNAL_SEGV:
690 case GDB_SIGNAL_PIPE:
692 case GDB_SIGNAL_ALRM:
694 case GDB_SIGNAL_TERM:
698 case GDB_SIGNAL_STOP:
700 case GDB_SIGNAL_TSTP:
702 case GDB_SIGNAL_CONT:
704 case GDB_SIGNAL_CHLD:
706 case GDB_SIGNAL_TTIN:
708 case GDB_SIGNAL_TTOU:
712 case GDB_SIGNAL_XCPU:
714 case GDB_SIGNAL_XFSZ:
716 case GDB_SIGNAL_VTALRM:
718 case GDB_SIGNAL_PROF:
720 case GDB_SIGNAL_WINCH:
724 case GDB_SIGNAL_USR1:
726 case GDB_SIGNAL_USR2:
751 for (i = 0; i < count; i++)
762 { 0x40000015,
"FATAL_APP_EXIT" },
763 { 0x4000001E,
"WX86_SINGLE_STEP" },
764 { 0x4000001F,
"WX86_BREAKPOINT" },
765 { 0x40010005,
"DBG_CONTROL_C" },
766 { 0x40010008,
"DBG_CONTROL_BREAK" },
767 { 0x80000002,
"DATATYPE_MISALIGNMENT" },
768 { 0x80000003,
"BREAKPOINT" },
769 { 0x80000004,
"SINGLE_STEP" },
770 { 0xC0000005,
"ACCESS_VIOLATION" },
771 { 0xC0000006,
"IN_PAGE_ERROR" },
772 { 0xC000001D,
"ILLEGAL_INSTRUCTION" },
773 { 0xC0000025,
"NONCONTINUABLE_EXCEPTION" },
774 { 0xC0000026,
"INVALID_DISPOSITION" },
775 { 0xC000008C,
"ARRAY_BOUNDS_EXCEEDED" },
776 { 0xC000008D,
"FLOAT_DENORMAL_OPERAND" },
777 { 0xC000008E,
"FLOAT_DIVIDE_BY_ZERO" },
778 { 0xC000008F,
"FLOAT_INEXACT_RESULT" },
779 { 0xC0000090,
"FLOAT_INVALID_OPERATION" },
780 { 0xC0000091,
"FLOAT_OVERFLOW" },
781 { 0xC0000092,
"FLOAT_STACK_CHECK" },
782 { 0xC0000093,
"FLOAT_UNDERFLOW" },
783 { 0xC0000094,
"INTEGER_DIVIDE_BY_ZERO" },
784 { 0xC0000095,
"INTEGER_OVERFLOW" },
785 { 0xC0000096,
"PRIV_INSTRUCTION" },
786 { 0xC00000FD,
"STACK_OVERFLOW" },
787 { 0xC0000409,
"FAST_FAIL" },
792 { 0,
"READ_ACCESS_VIOLATION" },
793 { 1,
"WRITE_ACCESS_VIOLATION" },
794 { 8,
"DATA_EXECUTION_PREVENTION_VIOLATION" },
803 struct type *dword_type, *pvoid_type, *ulongptr_type;
804 struct type *code_enum, *violation_enum;
805 struct type *violation_type, *para_type, *siginfo_ptr_type, *siginfo_type;
846 nullptr, siginfo_type);
859 para_type, ulongptr_type->
length ());
871 CORE_ADDR exec_base = 0;
908 if (vmaddr != exec_base)
990 asection *idata_section = bfd_get_section_by_name (abfd,
".idata");
991 if (idata_section ==
nullptr)
994 bfd_size_type idata_section_size = bfd_section_size (idata_section);
995 internal_extra_pe_aouthdr *pe_extra = &pe_data (abfd)->pe_opthdr;
996 bfd_vma import_table_va = pe_extra->DataDirectory[PE_IMPORT_TABLE].VirtualAddress;
997 bfd_vma idata_section_va = bfd_section_vma (idata_section);
1001 gdb_assert (idata_section_va >= pe_extra->ImageBase);
1002 idata_section_va -= pe_extra->ImageBase;
1004 bfd_vma idata_section_end_va = idata_section_va + idata_section_size;
1007 if (import_table_va < idata_section_va
1008 || import_table_va >= idata_section_end_va)
1011%s: import table's virtual address (%s) is outside .idata \
1012section's range [%s, %s]."),
1013 bfd_get_filename (abfd), hex_string (import_table_va),
1014 hex_string (idata_section_va),
1015 hex_string (idata_section_end_va));
1020 bfd_vma import_table_offset_in_sect = import_table_va - idata_section_va;
1023 gdb::byte_vector idata_contents;
1026 warning (_(
"%s: failed to get contents of .idata section."),
1027 bfd_get_filename (abfd));
1031 gdb_assert (idata_contents.size () == idata_section_size);
1033 const gdb_byte *iter = idata_contents.data () + import_table_offset_in_sect;
1034 const gdb_byte *end = idata_contents.data () + idata_section_size;
1043 warning (_(
"%s: unexpected end of .idata section."),
1044 bfd_get_filename (abfd));
1051 if (memcmp (dir_entry, &null_dir_entry,
1055 bfd_vma name_va = dir_entry->
name_rva;
1059 if (name_va < idata_section_va || name_va >= idata_section_end_va)
1062%s: name's virtual address (%s) is outside .idata section's \
1064 bfd_get_filename (abfd), hex_string (name_va),
1065 hex_string (idata_section_va),
1066 hex_string (idata_section_end_va));
1070 const gdb_byte *
name = &idata_contents[name_va - idata_section_va];
1100 unsigned int data_type;
1102 size_t module_name_size;
1103 size_t module_name_offset;
1104 CORE_ADDR base_addr;
1106 if (!startswith (sect->name,
".module"))
1109 gdb::byte_vector buf (bfd_section_size (sect) + 1);
1110 if (!bfd_get_section_contents (abfd, sect,
1111 buf.data (), 0, bfd_section_size (sect)))
1118 if (bfd_section_size (sect) < 4)
1124 module_name_offset = 12;
1125 if (bfd_section_size (sect) < module_name_offset)
1132 module_name_offset = 16;
1133 if (bfd_section_size (sect) < module_name_offset)
1141 if (module_name_offset + module_name_size > bfd_section_size (sect))
1143 module_name = (
char *) buf.data () + module_name_offset;
1146 if (data->module_count != 0)
1148 NULL, data->gdbarch, data->obstack);
1149 data->module_count++;
1155 ULONGEST offset, ULONGEST len)
1157 struct obstack obstack;
1163 obstack_grow_str (&
obstack,
"<library-list>\n");
1167 obstack_grow_str0 (&
obstack,
"</library-list>\n");
1169 buf = (
const char *) obstack_finish (&
obstack);
1170 len_avail = strlen (buf);
1171 if (offset >= len_avail)
1174 if (len > len_avail - offset)
1175 len = len_avail - offset;
1176 memcpy (readbuf, buf + offset, len);
1178 obstack_free (&
obstack, NULL);
1187 if (ptid.lwp () != 0)
1188 return string_printf (
"Thread 0x%lx", ptid.lwp ());
1200 _(
"Display thread information block."),
1207Set whether to display all non-zero fields of thread information block."), _(
"\
1208Show whether to display all non-zero fields of thread information block."), _(
"\
1209Use \"on\" to enable, \"off\" to disable.\n\
1210If enabled, all non-zero fields of thread information block are displayed,\n\
1211even if their meaning is unknown."),
struct gdbarch * target_gdbarch(void)
struct cmd_list_element * infolist
struct cmd_list_element * maintenance_show_cmdlist
struct cmd_list_element * maintenance_set_cmdlist
struct cmd_list_element * add_alias_cmd(const char *name, cmd_list_element *target, enum command_class theclass, int abbrev_flag, struct cmd_list_element **list)
struct cmd_list_element * add_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **list)
set_show_commands add_setshow_boolean_cmd(const char *name, enum command_class theclass, bool *var, const char *set_doc, const char *show_doc, const char *help_doc, cmd_func_ftype *set_func, show_value_ftype *show_func, struct cmd_list_element **set_list, struct cmd_list_element **show_list)
struct cmd_list_element * add_basic_prefix_cmd(const char *name, enum command_class theclass, const char *doc, struct cmd_list_element **subcommands, int allow_unknown, struct cmd_list_element **list)
CORE_ADDR pe_text_section_offset(struct bfd *abfd)
void store_typed_address(gdb_byte *buf, struct type *type, CORE_ADDR addr)
static ULONGEST extract_unsigned_integer(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order)
gdb_bfd_ref_ptr gdb_bfd_open(const char *name, const char *target, int fd, bool warn_if_slow)
bool gdb_bfd_get_full_section_contents(bfd *abfd, asection *section, gdb::byte_vector *contents)
gdb::ref_ptr< struct bfd, gdb_bfd_ref_policy > gdb_bfd_ref_ptr
enum bfd_endian gdbarch_byte_order(struct gdbarch *gdbarch)
void set_gdbarch_wchar_bit(struct gdbarch *gdbarch, int wchar_bit)
void set_gdbarch_has_dos_based_file_system(struct gdbarch *gdbarch, int has_dos_based_file_system)
void set_gdbarch_wchar_signed(struct gdbarch *gdbarch, int wchar_signed)
void set_gdbarch_get_siginfo_type(struct gdbarch *gdbarch, gdbarch_get_siginfo_type_ftype *get_siginfo_type)
int gdbarch_int_bit(struct gdbarch *gdbarch)
void set_gdbarch_iterate_over_objfiles_in_search_order(struct gdbarch *gdbarch, gdbarch_iterate_over_objfiles_in_search_order_ftype *iterate_over_objfiles_in_search_order)
void set_gdbarch_gdb_signal_to_target(struct gdbarch *gdbarch, gdbarch_gdb_signal_to_target_ftype *gdb_signal_to_target)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
void set_gdbarch_so_ops(struct gdbarch *gdbarch, const struct target_so_ops *so_ops)
gdb::function_view< bool(objfile *)> iterate_over_objfiles_in_search_order_cb_ftype
struct type * lookup_pointer_type(struct type *type)
struct type * init_integer_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
struct type * arch_composite_type(struct gdbarch *gdbarch, const char *name, enum type_code code)
struct type * lookup_array_range_type(struct type *element_type, LONGEST low_bound, LONGEST high_bound)
struct type * init_pointer_type(type_allocator &alloc, int bit, const char *name, struct type *target_type)
void append_composite_type_field_aligned(struct type *t, const char *name, struct type *field, int alignment)
void append_composite_type_field(struct type *t, const char *name, struct type *field)
struct type * check_typedef(struct type *type)
struct inferior * current_inferior(void)
void objfile_rebase(struct objfile *objfile, CORE_ADDR slide)
struct program_space * current_program_space
const struct target_so_ops solib_target_so_ops
void set_loc_enumval(LONGEST enumval)
void set_name(const char *name)
uint32_t import_address_table_rva
uint32_t import_lookup_table_rva
objfiles_range objfiles()
struct objfile * symfile_object_file
void(* solib_create_inferior_hook)(int from_tty)
struct field & field(int idx) const
void set_target_type(struct type *target_type)
void set_is_unsigned(bool is_unsigned)
void set_name(const char *name)
void alloc_fields(unsigned int nfields, bool init=true)
static struct value * allocate_computed(struct type *type, const struct lval_funcs *funcs, void *closure)
static struct value * allocate(struct type *type)
gdb::array_view< gdb_byte > contents_raw()
struct type * type() const
struct type * siginfo_type
struct type * tib_ptr_type
bool target_has_execution(inferior *inf)
LONGEST target_read(struct target_ops *ops, enum target_object object, const char *annex, gdb_byte *buf, ULONGEST offset, LONGEST len)
std::string target_pid_to_str(ptid_t ptid)
std::string normal_pid_to_str(ptid_t ptid)
bool target_get_tib_address(ptid_t ptid, CORE_ADDR *addr)
int target_read_memory(CORE_ADDR memaddr, gdb_byte *myaddr, ssize_t len)
const char * paddress(struct gdbarch *gdbarch, CORE_ADDR addr)
void gdb_printf(struct ui_file *stream, const char *format,...)
struct internalvar * create_internalvar_type_lazy(const char *name, const struct internalvar_funcs *funcs, void *data)
void windows_xfer_shared_library(const char *so_name, CORE_ADDR load_addr, CORE_ADDR *text_offset_cached, struct gdbarch *gdbarch, struct obstack *obstack)
static struct target_so_ops windows_so_ops
std::string windows_core_pid_to_str(struct gdbarch *gdbarch, ptid_t ptid)
static const struct enum_value_name violation_values[]
static void display_tib(const char *args, int from_tty)
bool is_linked_with_cygwin_dll(bfd *abfd)
static const char * TIB_NAME[]
void init_w32_command_list(void)
static void windows_iterate_over_objfiles_in_search_order(gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, objfile *current_objfile)
static const int FULL_TIB_SIZE
void _initialize_windows_tdep()
static void tlb_value_read(struct value *val)
static const registry< gdbarch >::key< windows_gdbarch_data > windows_gdbarch_data_handle
ULONGEST windows_core_xfer_shared_libraries(struct gdbarch *gdbarch, gdb_byte *readbuf, ULONGEST offset, ULONGEST len)
static int windows_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
static struct type * windows_get_tlb_type(struct gdbarch *gdbarch)
static void tlb_value_write(struct value *v, struct value *fromval)
static int w32_prefix_command_valid
static void core_process_module_section(bfd *abfd, asection *sect, void *obj)
static struct windows_gdbarch_data * get_windows_gdbarch_data(struct gdbarch *gdbarch)
static const struct lval_funcs tlb_value_funcs
void cygwin_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static const int MAX_TIB64
static struct value * tlb_make_value(struct gdbarch *gdbarch, struct internalvar *var, void *ignore)
static struct type * create_enum(struct gdbarch *gdbarch, int bit, const char *name, const struct enum_value_name *values, int count)
static const struct enum_value_name exception_values[]
static int display_one_tib(ptid_t ptid)
struct thread_information_block_64 thread_information_64
gdb_static_assert(sizeof(pe_import_directory_entry)==20)
static constexpr unsigned int NOTE_INFO_MODULE
void windows_init_abi(struct gdbarch_info info, struct gdbarch *gdbarch)
static struct type * windows_get_siginfo_type(struct gdbarch *gdbarch)
static constexpr unsigned int NOTE_INFO_MODULE64
static const int MAX_TIB32
struct cmd_list_element * info_w32_cmdlist
static int cygwin_gdb_signal_to_target(struct gdbarch *gdbarch, enum gdb_signal signal)
static bool maint_display_all_tib
static void windows_init_abi_common(struct gdbarch_info info, struct gdbarch *gdbarch)
struct thread_information_block_32 thread_information_32
static const struct internalvar_funcs tlb_funcs
static void windows_solib_create_inferior_hook(int from_tty)
static void show_maint_show_all_tib(struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value)