diff options
Diffstat (limited to 'gdb/windows-tdep.c')
-rw-r--r-- | gdb/windows-tdep.c | 117 |
1 files changed, 62 insertions, 55 deletions
diff --git a/gdb/windows-tdep.c b/gdb/windows-tdep.c index 0ba1472..e6571c7 100644 --- a/gdb/windows-tdep.c +++ b/gdb/windows-tdep.c @@ -36,7 +36,6 @@ #include "gdbcore.h" #include "coff/internal.h" #include "libcoff.h" -#include "solist.h" #define CYGWIN_DLL_NAME "cygwin1.dll" @@ -551,43 +550,6 @@ windows_xfer_shared_library (const char* so_name, CORE_ADDR load_addr, xml += "\"/></library>"; } -/* Implement the "iterate_over_objfiles_in_search_order" gdbarch - method. It searches all objfiles, starting with CURRENT_OBJFILE - first (if not NULL). - - On Windows, the system behaves a little differently when two - objfiles each define a global symbol using the same name, compared - to other platforms such as GNU/Linux for instance. On GNU/Linux, - all instances of the symbol effectively get merged into a single - one, but on Windows, they remain distinct. - - As a result, it usually makes sense to start global symbol searches - with the current objfile before expanding it to all other objfiles. - This helps for instance when a user debugs some code in a DLL that - refers to a global variable defined inside that DLL. When trying - to print the value of that global variable, it would be unhelpful - to print the value of another global variable defined with the same - name, but in a different DLL. */ - -static void -windows_iterate_over_objfiles_in_search_order - (gdbarch *gdbarch, iterate_over_objfiles_in_search_order_cb_ftype cb, - objfile *current_objfile) -{ - if (current_objfile) - { - if (cb (current_objfile)) - return; - } - - for (objfile *objfile : current_program_space->objfiles ()) - if (objfile != current_objfile) - { - if (cb (objfile)) - return; - } -} - static void show_maint_show_all_tib (struct ui_file *file, int from_tty, struct cmd_list_element *c, const char *value) @@ -863,10 +825,30 @@ windows_get_siginfo_type (struct gdbarch *gdbarch) return siginfo_type; } +/* solib_ops for Windows systems. */ + +struct windows_solib_ops : target_solib_ops +{ + using target_solib_ops::target_solib_ops; + + void create_inferior_hook (int from_tty) const override; + void iterate_over_objfiles_in_search_order + (iterate_over_objfiles_in_search_order_cb_ftype cb, + objfile *current_objfile) const override; +}; + +/* Return a new solib_ops for Windows systems. */ + +static solib_ops_up +make_windows_solib_ops (program_space *pspace) +{ + return std::make_unique<windows_solib_ops> (pspace); +} + /* Implement the "solib_create_inferior_hook" solib_ops method. */ -static void -windows_solib_create_inferior_hook (int from_tty) +void +windows_solib_ops::create_inferior_hook (int from_tty) const { CORE_ADDR exec_base = 0; @@ -911,7 +893,42 @@ windows_solib_create_inferior_hook (int from_tty) } } -static solib_ops windows_so_ops; +/* Implement the "iterate_over_objfiles_in_search_order" gdbarch + method. It searches all objfiles, starting with CURRENT_OBJFILE + first (if not NULL). + + On Windows, the system behaves a little differently when two + objfiles each define a global symbol using the same name, compared + to other platforms such as GNU/Linux for instance. On GNU/Linux, + all instances of the symbol effectively get merged into a single + one, but on Windows, they remain distinct. + + As a result, it usually makes sense to start global symbol searches + with the current objfile before expanding it to all other objfiles. + This helps for instance when a user debugs some code in a DLL that + refers to a global variable defined inside that DLL. When trying + to print the value of that global variable, it would be unhelpful + to print the value of another global variable defined with the same + name, but in a different DLL. */ + +void +windows_solib_ops::iterate_over_objfiles_in_search_order + (iterate_over_objfiles_in_search_order_cb_ftype cb, + objfile *current_objfile) const +{ + if (current_objfile) + { + if (cb (current_objfile)) + return; + } + + for (objfile &objfile : m_pspace->objfiles ()) + if (&objfile != current_objfile) + { + if (cb (&objfile)) + return; + } +} /* Common parts for gdbarch initialization for the Windows and Cygwin OS ABIs. */ @@ -926,13 +943,7 @@ windows_init_abi_common (struct gdbarch_info info, struct gdbarch *gdbarch) `c:\Program Files\Foo App\mydll.dll', for example. */ set_gdbarch_has_dos_based_file_system (gdbarch, 1); - set_gdbarch_iterate_over_objfiles_in_search_order - (gdbarch, windows_iterate_over_objfiles_in_search_order); - - windows_so_ops = solib_target_so_ops; - windows_so_ops.solib_create_inferior_hook - = windows_solib_create_inferior_hook; - set_gdbarch_so_ops (gdbarch, &windows_so_ops); + set_gdbarch_make_solib_ops (gdbarch, make_windows_solib_ops); set_gdbarch_get_siginfo_type (gdbarch, windows_get_siginfo_type); } @@ -1151,13 +1162,11 @@ core_process_module_section (bfd *abfd, asection *sect, void *obj) ULONGEST windows_core_xfer_shared_libraries (struct gdbarch *gdbarch, - gdb_byte *readbuf, + struct bfd &cbfd, gdb_byte *readbuf, ULONGEST offset, ULONGEST len) { cpms_data data { gdbarch, "<library-list>\n", 0 }; - bfd_map_over_sections (current_program_space->core_bfd (), - core_process_module_section, - &data); + bfd_map_over_sections (&cbfd, core_process_module_section, &data); data.xml += "</library-list>\n"; ULONGEST len_avail = data.xml.length (); @@ -1183,9 +1192,7 @@ windows_core_pid_to_str (struct gdbarch *gdbarch, ptid_t ptid) return normal_pid_to_str (ptid); } -void _initialize_windows_tdep (); -void -_initialize_windows_tdep () +INIT_GDB_FILE (windows_tdep) { init_w32_command_list (); cmd_list_element *info_w32_thread_information_block_cmd |