1 /* Copyright (C) 2008-2024 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 #include "windows-tdep.h"
19 #include "extract-store-integer.h"
20 #include "gdbsupport/gdb_obstack.h"
21 #include "xml-support.h"
27 #include "cli/cli-cmds.h"
28 #include "gdbthread.h"
31 #include "coff-pe-read.h"
34 #include "solib-target.h"
35 #include "frame-unwind.h"
37 #include "coff/internal.h"
41 #define CYGWIN_DLL_NAME "cygwin1.dll"
43 /* Windows signal numbers differ between MinGW flavors and between
44 those and Cygwin. The below enumerations were gleaned from the
45 respective headers. */
47 /* Signal numbers for the various MinGW flavors. The ones marked with
48 MinGW-w64 are defined by MinGW-w64, not by mingw.org's MinGW. */
52 WINDOWS_SIGHUP
= 1, /* MinGW-w64 */
54 WINDOWS_SIGQUIT
= 3, /* MinGW-w64 */
56 WINDOWS_SIGTRAP
= 5, /* MinGW-w64 */
57 WINDOWS_SIGIOT
= 6, /* MinGW-w64 */
58 WINDOWS_SIGEMT
= 7, /* MinGW-w64 */
60 WINDOWS_SIGKILL
= 9, /* MinGW-w64 */
61 WINDOWS_SIGBUS
= 10, /* MinGW-w64 */
63 WINDOWS_SIGSYS
= 12, /* MinGW-w64 */
64 WINDOWS_SIGPIPE
= 13, /* MinGW-w64 */
65 WINDOWS_SIGALRM
= 14, /* MinGW-w64 */
67 WINDOWS_SIGBREAK
= 21,
71 /* Signal numbers for Cygwin. */
100 CYGWIN_SIGVTALRM
= 26,
102 CYGWIN_SIGWINCH
= 28,
108 /* These constants are defined by Cygwin's core_dump.h */
109 static constexpr unsigned int NOTE_INFO_MODULE
= 3;
110 static constexpr unsigned int NOTE_INFO_MODULE64
= 4;
112 struct cmd_list_element
*info_w32_cmdlist
;
114 typedef struct thread_information_block_32
116 uint32_t current_seh
; /* %fs:0x0000 */
117 uint32_t current_top_of_stack
; /* %fs:0x0004 */
118 uint32_t current_bottom_of_stack
; /* %fs:0x0008 */
119 uint32_t sub_system_tib
; /* %fs:0x000c */
120 uint32_t fiber_data
; /* %fs:0x0010 */
121 uint32_t arbitrary_data_slot
; /* %fs:0x0014 */
122 uint32_t linear_address_tib
; /* %fs:0x0018 */
123 uint32_t environment_pointer
; /* %fs:0x001c */
124 uint32_t process_id
; /* %fs:0x0020 */
125 uint32_t current_thread_id
; /* %fs:0x0024 */
126 uint32_t active_rpc_handle
; /* %fs:0x0028 */
127 uint32_t thread_local_storage
; /* %fs:0x002c */
128 uint32_t process_environment_block
; /* %fs:0x0030 */
129 uint32_t last_error_number
; /* %fs:0x0034 */
131 thread_information_32
;
133 typedef struct thread_information_block_64
135 uint64_t current_seh
; /* %gs:0x0000 */
136 uint64_t current_top_of_stack
; /* %gs:0x0008 */
137 uint64_t current_bottom_of_stack
; /* %gs:0x0010 */
138 uint64_t sub_system_tib
; /* %gs:0x0018 */
139 uint64_t fiber_data
; /* %gs:0x0020 */
140 uint64_t arbitrary_data_slot
; /* %gs:0x0028 */
141 uint64_t linear_address_tib
; /* %gs:0x0030 */
142 uint64_t environment_pointer
; /* %gs:0x0038 */
143 uint64_t process_id
; /* %gs:0x0040 */
144 uint64_t current_thread_id
; /* %gs:0x0048 */
145 uint64_t active_rpc_handle
; /* %gs:0x0050 */
146 uint64_t thread_local_storage
; /* %gs:0x0058 */
147 uint64_t process_environment_block
; /* %gs:0x0060 */
148 uint64_t last_error_number
; /* %gs:0x0068 */
150 thread_information_64
;
153 static const char* TIB_NAME
[] =
155 " current_seh ", /* %fs:0x0000 */
156 " current_top_of_stack ", /* %fs:0x0004 */
157 " current_bottom_of_stack ", /* %fs:0x0008 */
158 " sub_system_tib ", /* %fs:0x000c */
159 " fiber_data ", /* %fs:0x0010 */
160 " arbitrary_data_slot ", /* %fs:0x0014 */
161 " linear_address_tib ", /* %fs:0x0018 */
162 " environment_pointer ", /* %fs:0x001c */
163 " process_id ", /* %fs:0x0020 */
164 " current_thread_id ", /* %fs:0x0024 */
165 " active_rpc_handle ", /* %fs:0x0028 */
166 " thread_local_storage ", /* %fs:0x002c */
167 " process_environment_block ", /* %fs:0x0030 */
168 " last_error_number " /* %fs:0x0034 */
171 static const int MAX_TIB32
=
172 sizeof (thread_information_32
) / sizeof (uint32_t);
173 static const int MAX_TIB64
=
174 sizeof (thread_information_64
) / sizeof (uint64_t);
175 static const int FULL_TIB_SIZE
= 0x1000;
177 static bool maint_display_all_tib
= false;
179 struct windows_gdbarch_data
181 struct type
*siginfo_type
= nullptr;
182 /* Type of thread information block. */
183 struct type
*tib_ptr_type
= nullptr;
186 static const registry
<gdbarch
>::key
<windows_gdbarch_data
>
187 windows_gdbarch_data_handle
;
189 /* Get windows_gdbarch_data of an arch. */
191 static struct windows_gdbarch_data
*
192 get_windows_gdbarch_data (struct gdbarch
*gdbarch
)
194 windows_gdbarch_data
*result
= windows_gdbarch_data_handle
.get (gdbarch
);
195 if (result
== nullptr)
196 result
= windows_gdbarch_data_handle
.emplace (gdbarch
);
200 /* Define Thread Local Base pointer type. */
203 windows_get_tlb_type (struct gdbarch
*gdbarch
)
205 struct type
*dword_ptr_type
, *dword32_type
, *void_ptr_type
;
206 struct type
*peb_ldr_type
, *peb_ldr_ptr_type
;
207 struct type
*peb_type
, *peb_ptr_type
, *list_type
;
208 struct type
*module_list_ptr_type
;
209 struct type
*tib_type
, *seh_type
, *tib_ptr_type
, *seh_ptr_type
;
210 struct type
*word_type
, *wchar_type
, *wchar_ptr_type
;
211 struct type
*uni_str_type
, *rupp_type
, *rupp_ptr_type
;
213 windows_gdbarch_data
*windows_gdbarch_data
214 = get_windows_gdbarch_data (gdbarch
);
215 if (windows_gdbarch_data
->tib_ptr_type
!= nullptr)
216 return windows_gdbarch_data
->tib_ptr_type
;
218 type_allocator
alloc (gdbarch
);
220 dword_ptr_type
= init_integer_type (alloc
, gdbarch_ptr_bit (gdbarch
),
222 dword32_type
= init_integer_type (alloc
, 32,
224 word_type
= init_integer_type (alloc
, 16,
226 wchar_type
= init_integer_type (alloc
, 16,
228 void_ptr_type
= lookup_pointer_type (builtin_type (gdbarch
)->builtin_void
);
229 wchar_ptr_type
= init_pointer_type (alloc
, gdbarch_ptr_bit (gdbarch
),
230 nullptr, wchar_type
);
234 list_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
235 list_type
->set_name (xstrdup ("list"));
237 module_list_ptr_type
= void_ptr_type
;
239 append_composite_type_field (list_type
, "forward_list",
240 module_list_ptr_type
);
241 append_composite_type_field (list_type
, "backward_list",
242 module_list_ptr_type
);
244 /* Structured Exception Handler */
246 seh_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
247 seh_type
->set_name (xstrdup ("seh"));
249 seh_ptr_type
= alloc
.new_type (TYPE_CODE_PTR
,
250 void_ptr_type
->length () * TARGET_CHAR_BIT
,
252 seh_ptr_type
->set_target_type (seh_type
);
254 append_composite_type_field (seh_type
, "next_seh", seh_ptr_type
);
255 append_composite_type_field (seh_type
, "handler",
256 builtin_type (gdbarch
)->builtin_func_ptr
);
258 /* struct _PEB_LDR_DATA */
259 peb_ldr_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
260 peb_ldr_type
->set_name (xstrdup ("peb_ldr_data"));
262 append_composite_type_field (peb_ldr_type
, "length", dword32_type
);
263 append_composite_type_field (peb_ldr_type
, "initialized", dword32_type
);
264 append_composite_type_field (peb_ldr_type
, "ss_handle", void_ptr_type
);
265 append_composite_type_field (peb_ldr_type
, "in_load_order", list_type
);
266 append_composite_type_field (peb_ldr_type
, "in_memory_order", list_type
);
267 append_composite_type_field (peb_ldr_type
, "in_init_order", list_type
);
268 append_composite_type_field (peb_ldr_type
, "entry_in_progress",
270 peb_ldr_ptr_type
= alloc
.new_type (TYPE_CODE_PTR
,
271 void_ptr_type
->length () * TARGET_CHAR_BIT
,
273 peb_ldr_ptr_type
->set_target_type (peb_ldr_type
);
275 /* struct UNICODE_STRING */
276 uni_str_type
= arch_composite_type (gdbarch
, "unicode_string",
279 append_composite_type_field (uni_str_type
, "length", word_type
);
280 append_composite_type_field (uni_str_type
, "maximum_length", word_type
);
281 append_composite_type_field_aligned (uni_str_type
, "buffer",
283 wchar_ptr_type
->length ());
285 /* struct _RTL_USER_PROCESS_PARAMETERS */
286 rupp_type
= arch_composite_type (gdbarch
, "rtl_user_process_parameters",
289 append_composite_type_field (rupp_type
, "maximum_length", dword32_type
);
290 append_composite_type_field (rupp_type
, "length", dword32_type
);
291 append_composite_type_field (rupp_type
, "flags", dword32_type
);
292 append_composite_type_field (rupp_type
, "debug_flags", dword32_type
);
293 append_composite_type_field (rupp_type
, "console_handle", void_ptr_type
);
294 append_composite_type_field (rupp_type
, "console_flags", dword32_type
);
295 append_composite_type_field_aligned (rupp_type
, "standard_input",
297 void_ptr_type
->length ());
298 append_composite_type_field (rupp_type
, "standard_output", void_ptr_type
);
299 append_composite_type_field (rupp_type
, "standard_error", void_ptr_type
);
300 append_composite_type_field (rupp_type
, "current_directory", uni_str_type
);
301 append_composite_type_field (rupp_type
, "current_directory_handle",
303 append_composite_type_field (rupp_type
, "dll_path", uni_str_type
);
304 append_composite_type_field (rupp_type
, "image_path_name", uni_str_type
);
305 append_composite_type_field (rupp_type
, "command_line", uni_str_type
);
306 append_composite_type_field (rupp_type
, "environment", void_ptr_type
);
307 append_composite_type_field (rupp_type
, "starting_x", dword32_type
);
308 append_composite_type_field (rupp_type
, "starting_y", dword32_type
);
309 append_composite_type_field (rupp_type
, "count_x", dword32_type
);
310 append_composite_type_field (rupp_type
, "count_y", dword32_type
);
311 append_composite_type_field (rupp_type
, "count_chars_x", dword32_type
);
312 append_composite_type_field (rupp_type
, "count_chars_y", dword32_type
);
313 append_composite_type_field (rupp_type
, "fill_attribute", dword32_type
);
314 append_composite_type_field (rupp_type
, "window_flags", dword32_type
);
315 append_composite_type_field (rupp_type
, "show_window_flags", dword32_type
);
316 append_composite_type_field_aligned (rupp_type
, "window_title",
318 void_ptr_type
->length ());
319 append_composite_type_field (rupp_type
, "desktop_info", uni_str_type
);
320 append_composite_type_field (rupp_type
, "shell_info", uni_str_type
);
321 append_composite_type_field (rupp_type
, "runtime_data", uni_str_type
);
323 rupp_ptr_type
= init_pointer_type (alloc
, gdbarch_ptr_bit (gdbarch
),
327 /* struct process environment block */
328 peb_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
329 peb_type
->set_name (xstrdup ("peb"));
331 /* First bytes contain several flags. */
332 append_composite_type_field (peb_type
, "flags", dword_ptr_type
);
333 append_composite_type_field (peb_type
, "mutant", void_ptr_type
);
334 append_composite_type_field (peb_type
, "image_base_address", void_ptr_type
);
335 append_composite_type_field (peb_type
, "ldr", peb_ldr_ptr_type
);
336 append_composite_type_field (peb_type
, "process_parameters", rupp_ptr_type
);
337 append_composite_type_field (peb_type
, "sub_system_data", void_ptr_type
);
338 append_composite_type_field (peb_type
, "process_heap", void_ptr_type
);
339 append_composite_type_field (peb_type
, "fast_peb_lock", void_ptr_type
);
340 peb_ptr_type
= alloc
.new_type (TYPE_CODE_PTR
,
341 void_ptr_type
->length () * TARGET_CHAR_BIT
,
343 peb_ptr_type
->set_target_type (peb_type
);
346 /* struct thread information block */
347 tib_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
348 tib_type
->set_name (xstrdup ("tib"));
350 /* uint32_t current_seh; %fs:0x0000 */
351 append_composite_type_field (tib_type
, "current_seh", seh_ptr_type
);
352 /* uint32_t current_top_of_stack; %fs:0x0004 */
353 append_composite_type_field (tib_type
, "current_top_of_stack",
355 /* uint32_t current_bottom_of_stack; %fs:0x0008 */
356 append_composite_type_field (tib_type
, "current_bottom_of_stack",
358 /* uint32_t sub_system_tib; %fs:0x000c */
359 append_composite_type_field (tib_type
, "sub_system_tib", void_ptr_type
);
361 /* uint32_t fiber_data; %fs:0x0010 */
362 append_composite_type_field (tib_type
, "fiber_data", void_ptr_type
);
363 /* uint32_t arbitrary_data_slot; %fs:0x0014 */
364 append_composite_type_field (tib_type
, "arbitrary_data_slot", void_ptr_type
);
365 /* uint32_t linear_address_tib; %fs:0x0018 */
366 append_composite_type_field (tib_type
, "linear_address_tib", void_ptr_type
);
367 /* uint32_t environment_pointer; %fs:0x001c */
368 append_composite_type_field (tib_type
, "environment_pointer", void_ptr_type
);
369 /* uint32_t process_id; %fs:0x0020 */
370 append_composite_type_field (tib_type
, "process_id", dword_ptr_type
);
371 /* uint32_t current_thread_id; %fs:0x0024 */
372 append_composite_type_field (tib_type
, "thread_id", dword_ptr_type
);
373 /* uint32_t active_rpc_handle; %fs:0x0028 */
374 append_composite_type_field (tib_type
, "active_rpc_handle", dword_ptr_type
);
375 /* uint32_t thread_local_storage; %fs:0x002c */
376 append_composite_type_field (tib_type
, "thread_local_storage",
378 /* uint32_t process_environment_block; %fs:0x0030 */
379 append_composite_type_field (tib_type
, "process_environment_block",
381 /* uint32_t last_error_number; %fs:0x0034 */
382 append_composite_type_field (tib_type
, "last_error_number", dword_ptr_type
);
384 tib_ptr_type
= alloc
.new_type (TYPE_CODE_PTR
,
385 void_ptr_type
->length () * TARGET_CHAR_BIT
,
387 tib_ptr_type
->set_target_type (tib_type
);
389 windows_gdbarch_data
->tib_ptr_type
= tib_ptr_type
;
394 /* The $_tlb convenience variable is a bit special. We don't know
395 for sure the type of the value until we actually have a chance to
396 fetch the data. The type can change depending on gdbarch, so it is
397 also dependent on which thread you have selected. */
399 /* This function implements the lval_computed support for reading a
403 tlb_value_read (struct value
*val
)
406 struct type
*type
= check_typedef (val
->type ());
408 if (!target_get_tib_address (inferior_ptid
, &tlb
))
409 error (_("Unable to read tlb"));
410 store_typed_address (val
->contents_raw ().data (), type
, tlb
);
413 /* This function implements the lval_computed support for writing a
417 tlb_value_write (struct value
*v
, struct value
*fromval
)
419 error (_("Impossible to change the Thread Local Base"));
422 static const struct lval_funcs tlb_value_funcs
=
429 /* Return a new value with the correct type for the tlb object of
430 the current thread using architecture GDBARCH. Return a void value
431 if there's no object available. */
433 static struct value
*
434 tlb_make_value (struct gdbarch
*gdbarch
, struct internalvar
*var
, void *ignore
)
436 if (target_has_stack () && inferior_ptid
!= null_ptid
)
438 struct type
*type
= windows_get_tlb_type (gdbarch
);
439 return value::allocate_computed (type
, &tlb_value_funcs
, NULL
);
442 return value::allocate (builtin_type (gdbarch
)->builtin_void
);
446 /* Display thread information block of a given thread. */
449 display_one_tib (ptid_t ptid
)
451 gdb_byte
*tib
= NULL
;
453 CORE_ADDR thread_local_base
;
454 ULONGEST i
, val
, max
, max_name
, size
, tib_size
;
455 ULONGEST sizeof_ptr
= gdbarch_ptr_bit (current_inferior ()->arch ());
456 bfd_endian byte_order
= gdbarch_byte_order (current_inferior ()->arch ());
458 if (sizeof_ptr
== 64)
460 size
= sizeof (uint64_t);
461 tib_size
= sizeof (thread_information_64
);
466 size
= sizeof (uint32_t);
467 tib_size
= sizeof (thread_information_32
);
473 if (maint_display_all_tib
)
475 tib_size
= FULL_TIB_SIZE
;
476 max
= tib_size
/ size
;
479 tib
= (gdb_byte
*) alloca (tib_size
);
481 if (target_get_tib_address (ptid
, &thread_local_base
) == 0)
483 gdb_printf (_("Unable to get thread local base for %s\n"),
484 target_pid_to_str (ptid
).c_str ());
488 if (target_read (current_inferior ()->top_target (), TARGET_OBJECT_MEMORY
,
489 NULL
, tib
, thread_local_base
, tib_size
) != tib_size
)
491 gdb_printf (_("Unable to read thread information "
492 "block for %s at address %s\n"),
493 target_pid_to_str (ptid
).c_str (),
494 paddress (current_inferior ()->arch (), thread_local_base
));
498 gdb_printf (_("Thread Information Block %s at %s\n"),
499 target_pid_to_str (ptid
).c_str (),
500 paddress (current_inferior ()->arch (), thread_local_base
));
502 index
= (gdb_byte
*) tib
;
504 /* All fields have the size of a pointer, this allows to iterate
505 using the same for loop for both layouts. */
506 for (i
= 0; i
< max
; i
++)
508 val
= extract_unsigned_integer (index
, size
, byte_order
);
510 gdb_printf (_("%s is 0x%s\n"), TIB_NAME
[i
], phex (val
, size
));
512 gdb_printf (_("TIB[0x%s] is 0x%s\n"), phex (i
* size
, 2),
519 /* Display thread information block of the current thread. */
522 display_tib (const char * args
, int from_tty
)
524 if (inferior_ptid
!= null_ptid
)
525 display_one_tib (inferior_ptid
);
529 windows_xfer_shared_library (const char* so_name
, CORE_ADDR load_addr
,
530 CORE_ADDR
*text_offset_cached
,
531 struct gdbarch
*gdbarch
, std::string
&xml
)
533 CORE_ADDR text_offset
= text_offset_cached
? *text_offset_cached
: 0;
535 xml
+= "<library name=\"";
536 xml_escape_text_append (xml
, so_name
);
537 xml
+= "\"><segment address=\"";
541 gdb_bfd_ref_ptr
dll (gdb_bfd_open (so_name
, gnutarget
));
542 /* The following calls are OK even if dll is NULL.
543 The default value 0x1000 is returned by pe_text_section_offset
545 text_offset
= pe_text_section_offset (dll
.get ());
546 if (text_offset_cached
)
547 *text_offset_cached
= text_offset
;
550 xml
+= paddress (gdbarch
, load_addr
+ text_offset
);
551 xml
+= "\"/></library>";
554 /* Implement the "iterate_over_objfiles_in_search_order" gdbarch
555 method. It searches all objfiles, starting with CURRENT_OBJFILE
558 On Windows, the system behaves a little differently when two
559 objfiles each define a global symbol using the same name, compared
560 to other platforms such as GNU/Linux for instance. On GNU/Linux,
561 all instances of the symbol effectively get merged into a single
562 one, but on Windows, they remain distinct.
564 As a result, it usually makes sense to start global symbol searches
565 with the current objfile before expanding it to all other objfiles.
566 This helps for instance when a user debugs some code in a DLL that
567 refers to a global variable defined inside that DLL. When trying
568 to print the value of that global variable, it would be unhelpful
569 to print the value of another global variable defined with the same
570 name, but in a different DLL. */
573 windows_iterate_over_objfiles_in_search_order
574 (gdbarch
*gdbarch
, iterate_over_objfiles_in_search_order_cb_ftype cb
,
575 objfile
*current_objfile
)
579 if (cb (current_objfile
))
583 for (objfile
*objfile
: current_program_space
->objfiles ())
584 if (objfile
!= current_objfile
)
592 show_maint_show_all_tib (struct ui_file
*file
, int from_tty
,
593 struct cmd_list_element
*c
, const char *value
)
595 gdb_printf (file
, _("Show all non-zero elements of "
596 "Thread Information Block is %s.\n"), value
);
600 static int w32_prefix_command_valid
= 0;
602 init_w32_command_list (void)
604 if (!w32_prefix_command_valid
)
608 _("Print information specific to Win32 debugging."),
609 &info_w32_cmdlist
, 0, &infolist
);
610 w32_prefix_command_valid
= 1;
614 /* Implementation of `gdbarch_gdb_signal_to_target' for Windows. */
617 windows_gdb_signal_to_target (struct gdbarch
*gdbarch
, enum gdb_signal signal
)
624 return WINDOWS_SIGHUP
;
626 return WINDOWS_SIGINT
;
627 case GDB_SIGNAL_QUIT
:
628 return WINDOWS_SIGQUIT
;
630 return WINDOWS_SIGILL
;
631 case GDB_SIGNAL_TRAP
:
632 return WINDOWS_SIGTRAP
;
633 case GDB_SIGNAL_ABRT
:
634 return WINDOWS_SIGABRT
;
636 return WINDOWS_SIGEMT
;
638 return WINDOWS_SIGFPE
;
639 case GDB_SIGNAL_KILL
:
640 return WINDOWS_SIGKILL
;
642 return WINDOWS_SIGBUS
;
643 case GDB_SIGNAL_SEGV
:
644 return WINDOWS_SIGSEGV
;
646 return WINDOWS_SIGSYS
;
647 case GDB_SIGNAL_PIPE
:
648 return WINDOWS_SIGPIPE
;
649 case GDB_SIGNAL_ALRM
:
650 return WINDOWS_SIGALRM
;
651 case GDB_SIGNAL_TERM
:
652 return WINDOWS_SIGTERM
;
657 /* Implementation of `gdbarch_gdb_signal_to_target' for Cygwin. */
660 cygwin_gdb_signal_to_target (struct gdbarch
*gdbarch
, enum gdb_signal signal
)
667 return CYGWIN_SIGHUP
;
669 return CYGWIN_SIGINT
;
670 case GDB_SIGNAL_QUIT
:
671 return CYGWIN_SIGQUIT
;
673 return CYGWIN_SIGILL
;
674 case GDB_SIGNAL_TRAP
:
675 return CYGWIN_SIGTRAP
;
676 case GDB_SIGNAL_ABRT
:
677 return CYGWIN_SIGABRT
;
679 return CYGWIN_SIGEMT
;
681 return CYGWIN_SIGFPE
;
682 case GDB_SIGNAL_KILL
:
683 return CYGWIN_SIGKILL
;
685 return CYGWIN_SIGBUS
;
686 case GDB_SIGNAL_SEGV
:
687 return CYGWIN_SIGSEGV
;
689 return CYGWIN_SIGSYS
;
690 case GDB_SIGNAL_PIPE
:
691 return CYGWIN_SIGPIPE
;
692 case GDB_SIGNAL_ALRM
:
693 return CYGWIN_SIGALRM
;
694 case GDB_SIGNAL_TERM
:
695 return CYGWIN_SIGTERM
;
697 return CYGWIN_SIGURG
;
698 case GDB_SIGNAL_STOP
:
699 return CYGWIN_SIGSTOP
;
700 case GDB_SIGNAL_TSTP
:
701 return CYGWIN_SIGTSTP
;
702 case GDB_SIGNAL_CONT
:
703 return CYGWIN_SIGCONT
;
704 case GDB_SIGNAL_CHLD
:
705 return CYGWIN_SIGCHLD
;
706 case GDB_SIGNAL_TTIN
:
707 return CYGWIN_SIGTTIN
;
708 case GDB_SIGNAL_TTOU
:
709 return CYGWIN_SIGTTOU
;
712 case GDB_SIGNAL_XCPU
:
713 return CYGWIN_SIGXCPU
;
714 case GDB_SIGNAL_XFSZ
:
715 return CYGWIN_SIGXFSZ
;
716 case GDB_SIGNAL_VTALRM
:
717 return CYGWIN_SIGVTALRM
;
718 case GDB_SIGNAL_PROF
:
719 return CYGWIN_SIGPROF
;
720 case GDB_SIGNAL_WINCH
:
721 return CYGWIN_SIGWINCH
;
723 return CYGWIN_SIGLOST
;
724 case GDB_SIGNAL_USR1
:
725 return CYGWIN_SIGUSR1
;
726 case GDB_SIGNAL_USR2
:
727 return CYGWIN_SIGUSR2
;
732 struct enum_value_name
738 /* Allocate a TYPE_CODE_ENUM type structure with its named values. */
741 create_enum (struct gdbarch
*gdbarch
, int bit
, const char *name
,
742 const struct enum_value_name
*values
, int count
)
747 type
= type_allocator (gdbarch
).new_type (TYPE_CODE_ENUM
, bit
, name
);
748 type
->alloc_fields (count
);
749 type
->set_is_unsigned (true);
751 for (i
= 0; i
< count
; i
++)
753 type
->field (i
).set_name (values
[i
].name
);
754 type
->field (i
).set_loc_enumval (values
[i
].value
);
760 static const struct enum_value_name exception_values
[] =
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" },
790 static const struct enum_value_name violation_values
[] =
792 { 0, "READ_ACCESS_VIOLATION" },
793 { 1, "WRITE_ACCESS_VIOLATION" },
794 { 8, "DATA_EXECUTION_PREVENTION_VIOLATION" },
797 /* Implement the "get_siginfo_type" gdbarch method. */
800 windows_get_siginfo_type (struct gdbarch
*gdbarch
)
802 struct windows_gdbarch_data
*windows_gdbarch_data
;
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
;
807 windows_gdbarch_data
= get_windows_gdbarch_data (gdbarch
);
808 if (windows_gdbarch_data
->siginfo_type
!= NULL
)
809 return windows_gdbarch_data
->siginfo_type
;
811 type_allocator
alloc (gdbarch
);
812 dword_type
= init_integer_type (alloc
, gdbarch_int_bit (gdbarch
),
814 pvoid_type
= init_pointer_type (alloc
, gdbarch_ptr_bit (gdbarch
), "PVOID",
815 builtin_type (gdbarch
)->builtin_void
);
816 ulongptr_type
= init_integer_type (alloc
, gdbarch_ptr_bit (gdbarch
),
819 /* ExceptionCode value names */
820 code_enum
= create_enum (gdbarch
, gdbarch_int_bit (gdbarch
),
821 "ExceptionCode", exception_values
,
822 ARRAY_SIZE (exception_values
));
824 /* ACCESS_VIOLATION type names */
825 violation_enum
= create_enum (gdbarch
, gdbarch_ptr_bit (gdbarch
),
826 "ViolationType", violation_values
,
827 ARRAY_SIZE (violation_values
));
829 /* ACCESS_VIOLATION information */
830 violation_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_STRUCT
);
831 append_composite_type_field (violation_type
, "Type", violation_enum
);
832 append_composite_type_field (violation_type
, "Address", pvoid_type
);
834 /* Unnamed union of the documented field ExceptionInformation,
835 and the alternative AccessViolationInformation (which displays
836 human-readable values for ExceptionCode ACCESS_VIOLATION). */
837 para_type
= arch_composite_type (gdbarch
, NULL
, TYPE_CODE_UNION
);
838 append_composite_type_field (para_type
, "ExceptionInformation",
839 lookup_array_range_type (ulongptr_type
, 0, 14));
840 append_composite_type_field (para_type
, "AccessViolationInformation",
843 siginfo_type
= arch_composite_type (gdbarch
, "EXCEPTION_RECORD",
845 siginfo_ptr_type
= init_pointer_type (alloc
, gdbarch_ptr_bit (gdbarch
),
846 nullptr, siginfo_type
);
848 /* ExceptionCode is documented as type DWORD, but here a helper
849 enum type is used instead to display a human-readable value. */
850 append_composite_type_field (siginfo_type
, "ExceptionCode", code_enum
);
851 append_composite_type_field (siginfo_type
, "ExceptionFlags", dword_type
);
852 append_composite_type_field (siginfo_type
, "ExceptionRecord",
854 append_composite_type_field (siginfo_type
, "ExceptionAddress",
856 append_composite_type_field (siginfo_type
, "NumberParameters", dword_type
);
857 /* The 64-bit variant needs some padding. */
858 append_composite_type_field_aligned (siginfo_type
, "",
859 para_type
, ulongptr_type
->length ());
861 windows_gdbarch_data
->siginfo_type
= siginfo_type
;
866 /* Implement the "solib_create_inferior_hook" solib_ops method. */
869 windows_solib_create_inferior_hook (int from_tty
)
871 CORE_ADDR exec_base
= 0;
873 /* Find base address of main executable in
874 TIB->process_environment_block->image_base_address. */
875 gdbarch
*gdbarch
= current_inferior ()->arch ();
876 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
878 int peb_offset
; /* Offset of process_environment_block in TIB. */
879 int base_offset
; /* Offset of image_base_address in PEB. */
880 if (gdbarch_ptr_bit (gdbarch
) == 32)
894 if (target_has_execution ()
895 && target_get_tib_address (inferior_ptid
, &tlb
)
896 && !target_read_memory (tlb
+ peb_offset
, buf
, ptr_bytes
))
898 CORE_ADDR peb
= extract_unsigned_integer (buf
, ptr_bytes
, byte_order
);
899 if (!target_read_memory (peb
+ base_offset
, buf
, ptr_bytes
))
900 exec_base
= extract_unsigned_integer (buf
, ptr_bytes
, byte_order
);
903 /* Rebase executable if the base address changed because of ASLR. */
904 if (current_program_space
->symfile_object_file
!= nullptr && exec_base
!= 0)
907 = pe_data (current_program_space
->exec_bfd ())->pe_opthdr
.ImageBase
;
908 if (vmaddr
!= exec_base
)
909 objfile_rebase (current_program_space
->symfile_object_file
,
914 static solib_ops windows_so_ops
;
916 /* Common parts for gdbarch initialization for the Windows and Cygwin OS
920 windows_init_abi_common (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
922 set_gdbarch_wchar_bit (gdbarch
, 16);
923 set_gdbarch_wchar_signed (gdbarch
, 0);
925 /* Canonical paths on this target look like
926 `c:\Program Files\Foo App\mydll.dll', for example. */
927 set_gdbarch_has_dos_based_file_system (gdbarch
, 1);
929 set_gdbarch_iterate_over_objfiles_in_search_order
930 (gdbarch
, windows_iterate_over_objfiles_in_search_order
);
932 windows_so_ops
= solib_target_so_ops
;
933 windows_so_ops
.solib_create_inferior_hook
934 = windows_solib_create_inferior_hook
;
935 set_gdbarch_so_ops (gdbarch
, &windows_so_ops
);
937 set_gdbarch_get_siginfo_type (gdbarch
, windows_get_siginfo_type
);
940 /* See windows-tdep.h. */
942 windows_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
944 windows_init_abi_common (info
, gdbarch
);
945 set_gdbarch_gdb_signal_to_target (gdbarch
, windows_gdb_signal_to_target
);
948 /* See windows-tdep.h. */
951 cygwin_init_abi (struct gdbarch_info info
, struct gdbarch
*gdbarch
)
953 windows_init_abi_common (info
, gdbarch
);
954 set_gdbarch_gdb_signal_to_target (gdbarch
, cygwin_gdb_signal_to_target
);
957 /* Implementation of `tlb' variable. */
959 static const struct internalvar_funcs tlb_funcs
=
965 /* Layout of an element of a PE's Import Directory Table. Based on:
967 https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-directory-table
970 struct pe_import_directory_entry
972 uint32_t import_lookup_table_rva
;
974 uint32_t forwarder_chain
;
976 uint32_t import_address_table_rva
;
979 static_assert (sizeof (pe_import_directory_entry
) == 20);
981 /* See windows-tdep.h. */
984 is_linked_with_cygwin_dll (bfd
*abfd
)
986 /* The list of DLLs a PE is linked to is in the .idata section. See:
988 https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#the-idata-section
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
);
999 /* The section's virtual address as reported by BFD has the image base applied,
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
;
1006 /* Make sure that the import table is indeed within the .idata section's range. */
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 \
1012 section'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
));
1019 /* The import table starts at this offset into the .idata section. */
1020 bfd_vma import_table_offset_in_sect
= import_table_va
- idata_section_va
;
1022 /* Get the section's data. */
1023 gdb::byte_vector idata_contents
;
1024 if (!gdb_bfd_get_full_section_contents (abfd
, idata_section
, &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
;
1035 const pe_import_directory_entry null_dir_entry
= { 0 };
1037 /* Iterate through all directory entries. */
1040 /* Is there enough space left in the section for another entry? */
1041 if (iter
+ sizeof (pe_import_directory_entry
) > end
)
1043 warning (_("%s: unexpected end of .idata section."),
1044 bfd_get_filename (abfd
));
1048 pe_import_directory_entry
*dir_entry
= (pe_import_directory_entry
*) iter
;
1050 /* Is it the end of list marker? */
1051 if (memcmp (dir_entry
, &null_dir_entry
,
1052 sizeof (pe_import_directory_entry
)) == 0)
1055 bfd_vma name_va
= dir_entry
->name_rva
;
1057 /* If the name's virtual address is smaller than the section's virtual
1058 address, there's a problem. */
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
];
1072 /* Make sure we don't overshoot the end of the section with the
1074 if (name
+ sizeof (CYGWIN_DLL_NAME
) <= end
)
1076 /* Finally, check if this is the dll name we are looking for. */
1077 if (streq ((const char *) name
, CYGWIN_DLL_NAME
))
1081 iter
+= sizeof (pe_import_directory_entry
);
1089 struct gdbarch
*gdbarch
;
1095 core_process_module_section (bfd
*abfd
, asection
*sect
, void *obj
)
1097 struct cpms_data
*data
= (struct cpms_data
*) obj
;
1098 enum bfd_endian byte_order
= gdbarch_byte_order (data
->gdbarch
);
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
)))
1113 /* We're going to treat part of the buffer as a string, so make sure
1114 it is NUL-terminated. */
1117 /* A DWORD (data_type) followed by struct windows_core_module_info. */
1118 if (bfd_section_size (sect
) < 4)
1120 data_type
= extract_unsigned_integer (buf
.data (), 4, byte_order
);
1122 if (data_type
== NOTE_INFO_MODULE
)
1124 module_name_offset
= 12;
1125 if (bfd_section_size (sect
) < module_name_offset
)
1127 base_addr
= extract_unsigned_integer (&buf
[4], 4, byte_order
);
1128 module_name_size
= extract_unsigned_integer (&buf
[8], 4, byte_order
);
1130 else if (data_type
== NOTE_INFO_MODULE64
)
1132 module_name_offset
= 16;
1133 if (bfd_section_size (sect
) < module_name_offset
)
1135 base_addr
= extract_unsigned_integer (&buf
[4], 8, byte_order
);
1136 module_name_size
= extract_unsigned_integer (&buf
[12], 4, byte_order
);
1141 if (module_name_offset
+ module_name_size
> bfd_section_size (sect
))
1143 module_name
= (char *) buf
.data () + module_name_offset
;
1145 /* The first module is the .exe itself. */
1146 if (data
->module_count
!= 0)
1147 windows_xfer_shared_library (module_name
, base_addr
,
1148 NULL
, data
->gdbarch
, data
->xml
);
1149 data
->module_count
++;
1153 windows_core_xfer_shared_libraries (struct gdbarch
*gdbarch
,
1155 ULONGEST offset
, ULONGEST len
)
1157 cpms_data data
{ gdbarch
, "<library-list>\n", 0 };
1158 bfd_map_over_sections (current_program_space
->core_bfd (),
1159 core_process_module_section
,
1161 data
.xml
+= "</library-list>\n";
1163 ULONGEST len_avail
= data
.xml
.length ();
1164 if (offset
>= len_avail
)
1167 if (len
> len_avail
- offset
)
1168 len
= len_avail
- offset
;
1170 memcpy (readbuf
, data
.xml
.data () + offset
, len
);
1175 /* This is how we want PTIDs from core files to be printed. */
1178 windows_core_pid_to_str (struct gdbarch
*gdbarch
, ptid_t ptid
)
1180 if (ptid
.lwp () != 0)
1181 return string_printf ("Thread 0x%lx", ptid
.lwp ());
1183 return normal_pid_to_str (ptid
);
1186 void _initialize_windows_tdep ();
1188 _initialize_windows_tdep ()
1190 init_w32_command_list ();
1191 cmd_list_element
*info_w32_thread_information_block_cmd
1192 = add_cmd ("thread-information-block", class_info
, display_tib
,
1193 _("Display thread information block."),
1195 add_alias_cmd ("tib", info_w32_thread_information_block_cmd
, class_info
, 1,
1198 add_setshow_boolean_cmd ("show-all-tib", class_maintenance
,
1199 &maint_display_all_tib
, _("\
1200 Set whether to display all non-zero fields of thread information block."), _("\
1201 Show whether to display all non-zero fields of thread information block."), _("\
1202 Use \"on\" to enable, \"off\" to disable.\n\
1203 If enabled, all non-zero fields of thread information block are displayed,\n\
1204 even if their meaning is unknown."),
1206 show_maint_show_all_tib
,
1207 &maintenance_set_cmdlist
,
1208 &maintenance_show_cmdlist
);
1210 /* Explicitly create without lookup, since that tries to create a
1211 value with a void typed value, and when we get here, gdbarch
1212 isn't initialized yet. At this point, we're quite sure there
1213 isn't another convenience variable of the same name. */
1214 create_internalvar_type_lazy ("_tlb", &tlb_funcs
, NULL
);
1217 /* Frame cache data for the cygwin sigwrapper unwinder. */
1219 struct cygwin_sigwrapper_frame_cache
1225 /* Return true if the instructions at PC match the instructions bytes
1226 in PATTERN. Returns false otherwise. */
1229 insns_match_pattern (CORE_ADDR pc
,
1230 const gdb::array_view
<const gdb_byte
> pattern
)
1232 for (size_t i
= 0; i
< pattern
.size (); i
++)
1235 if (target_read_code (pc
+ i
, &buf
, 1) != 0)
1237 if (buf
!= pattern
[i
])
1243 /* Helper for cygwin_sigwrapper_frame_cache. Search for one of the
1244 patterns in PATTERNS_LIST within [START, END). If found, record
1245 the tls offset found after the matched pattern in the instruction
1246 stream, in *TLSOFFSET. */
1249 cygwin_sigwrapper_frame_analyze
1250 (struct gdbarch
*gdbarch
,
1251 CORE_ADDR start
, CORE_ADDR end
,
1252 gdb::array_view
<const gdb::array_view
<const gdb_byte
>> patterns_list
,
1255 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1259 for (CORE_ADDR addr
= start
; addr
< end
; addr
++)
1261 for (auto patterns
: patterns_list
)
1263 if (insns_match_pattern (addr
, patterns
))
1265 /* The instruction sequence is followed by 4 bytes for
1267 gdb_byte tls_stackptr
[4];
1268 if (target_read_code (addr
+ patterns
.size (), tls_stackptr
, 4) == 0)
1270 *tlsoffset
= extract_signed_integer (tls_stackptr
, 4, byte_order
);
1272 frame_debug_printf ("matched pattern at %s, sigstackptroffset=%x",
1273 paddress (gdbarch
, addr
),
1281 /* XXX: Perhaps we should also note the address of the xaddq
1282 instruction which pops the RA from the sigstack. If PC is after
1283 that, we should look in the appropriate register to get the RA,
1284 not on the sigstack. */
1287 /* Fill THIS_CACHE using the cygwin sigwrapper unwinding data for
1290 static cygwin_sigwrapper_frame_cache
*
1291 cygwin_sigwrapper_frame_cache (frame_info_ptr this_frame
, void **this_cache
)
1293 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1294 enum bfd_endian byte_order
= gdbarch_byte_order (gdbarch
);
1295 auto *cache
= (struct cygwin_sigwrapper_frame_cache
*) *this_cache
;
1296 const int len
= gdbarch_addr_bit (gdbarch
) / 8;
1298 /* Get address of top of stack from thread information block. */
1299 CORE_ADDR thread_local_base
;
1300 target_get_tib_address (inferior_ptid
, &thread_local_base
);
1303 = read_memory_unsigned_integer (thread_local_base
+ len
, len
, byte_order
);
1305 frame_debug_printf ("TEB.stacktop=%s", paddress (gdbarch
, stacktop
));
1307 /* Find cygtls, relative to stacktop, and read signalstackptr from
1309 CORE_ADDR signalstackptr
1310 = read_memory_unsigned_integer (stacktop
+ cache
->tlsoffset
,
1313 frame_debug_printf ("sigsp=%s", paddress (gdbarch
, signalstackptr
));
1315 /* Read return address from signal stack. */
1317 = read_memory_unsigned_integer (signalstackptr
- len
, len
, byte_order
);
1319 frame_debug_printf ("ra=%s", paddress (gdbarch
, cache
->prev_pc
));
1324 static struct value
*
1325 cygwin_sigwrapper_frame_prev_register (const frame_info_ptr
&this_frame
,
1329 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1330 struct cygwin_sigwrapper_frame_cache
*cache
1331 = cygwin_sigwrapper_frame_cache (this_frame
, this_cache
);
1333 frame_debug_printf ("%s for pc=%s",
1334 gdbarch_register_name (gdbarch
, regnum
),
1335 paddress (gdbarch
, cache
->prev_pc
));
1337 if (regnum
== gdbarch_pc_regnum (gdbarch
))
1338 return frame_unwind_got_address (this_frame
, regnum
, cache
->prev_pc
);
1340 return frame_unwind_got_register (this_frame
, regnum
, regnum
);
1344 cygwin_sigwrapper_frame_this_id (const frame_info_ptr
&this_frame
,
1346 struct frame_id
*this_id
)
1348 *this_id
= frame_id_build_unavailable_stack (get_frame_func (this_frame
));
1352 cygwin_sigwrapper_frame_sniffer (const struct frame_unwind
*self_
,
1353 const frame_info_ptr
&this_frame
,
1356 const auto *self
= (const struct cygwin_sigwrapper_frame_unwind
*) self_
;
1357 struct gdbarch
*gdbarch
= get_frame_arch (this_frame
);
1359 CORE_ADDR pc
= get_frame_pc (this_frame
);
1361 CORE_ADDR start
, end
;
1362 find_pc_partial_function (pc
, &name
, &start
, &end
);
1364 if (name
== nullptr)
1367 if (strcmp (name
, "_sigbe") != 0
1368 && strcmp (name
, "__sigbe") != 0
1369 && strcmp (name
, "sigdelayed") != 0
1370 && strcmp (name
, "_sigdelayed") != 0)
1373 frame_debug_printf ("name=%s, start=%s, end=%s",
1375 paddress (gdbarch
, start
),
1376 paddress (gdbarch
, end
));
1379 cygwin_sigwrapper_frame_analyze (gdbarch
, start
, end
, self
->patterns_list
,
1384 frame_debug_printf ("sigstackptroffset=%x", tlsoffset
);
1386 auto *cache
= FRAME_OBSTACK_ZALLOC (struct cygwin_sigwrapper_frame_cache
);
1387 cache
->tlsoffset
= tlsoffset
;
1389 *this_cache
= cache
;
1390 cygwin_sigwrapper_frame_cache (this_frame
, this_cache
);
1395 /* Cygwin sigwapper unwinder. */
1397 cygwin_sigwrapper_frame_unwind::cygwin_sigwrapper_frame_unwind
1398 (gdb::array_view
<const gdb::array_view
<const gdb_byte
>> patterns_list
)
1400 patterns_list (patterns_list
)
1402 name
= "cygwin sigwrapper";
1403 type
= NORMAL_FRAME
;
1404 stop_reason
= default_frame_unwind_stop_reason
;
1405 this_id
= cygwin_sigwrapper_frame_this_id
;
1406 prev_register
= cygwin_sigwrapper_frame_prev_register
;
1407 sniffer
= cygwin_sigwrapper_frame_sniffer
;