forked from Imagelibrary/binutils-gdb
Replace code accessing list implementation details with API calls.
* dll.c (clear_dlls): Replace accessing list implemention details with API function. * gdbthread.h (get_first_thread): Declare. * inferiors.c (for_each_inferior_with_data): New function. (get_first_thread): New function. (find_thread_ptid): Simplify. (get_first_inferior): New function. (clear_list): Delete. (one_inferior_p): New function. (clear_inferior_list): New function. (clear_inferiors): Update. * inferiors.h (for_each_inferior_with_data): Declare. (clear_inferior_list): Declare. (one_inferior_p): Declare. (get_first_inferior): Declare. * linux-low.c (linux_wait_for_event): Replace accessing list implemention details with API function. * server.c (target_running): Ditto. (accumulate_file_name_length): New function. (emit_dll_description): New function. (handle_qxfer_libraries): Replace accessing list implemention details with API function. (handle_qxfer_threads_worker): New function. (handle_qxfer_threads_proper): Replace accessing list implemention details with API function. (handle_query): Ditto. (visit_actioned_threads_callback_ftype): New typedef. (visit_actioned_threads_data): New struct. (visit_actioned_threads): Rewrite to be find_inferior callback. (resume): Call find_inferior. (handle_status): Replace accessing list implemention details with API function. (process_serial_event): Replace accessing list implemention details with API function. * target.c (set_desired_inferior): Replace accessing list implemention details with API function. * tracepoint.c (same_process_p): New function. (gdb_agent_about_to_close): Replace accessing list implemention details with API function. * win32-low.c (child_delete_thread): Replace accessing list implemention details with API function. (match_dll_by_basename): New function. (dll_is_loaded_by_basename): New function. (win32_ensure_ntdll_loaded): Replace accessing list implemention details call to dll_is_loaded_by_basename.
This commit is contained in:
@@ -232,7 +232,7 @@ child_delete_thread (DWORD pid, DWORD tid)
|
||||
ptid_t ptid;
|
||||
|
||||
/* If the last thread is exiting, just return. */
|
||||
if (all_threads.head == all_threads.tail)
|
||||
if (one_inferior_p (&all_threads))
|
||||
return;
|
||||
|
||||
ptid = ptid_build (pid, tid, 0);
|
||||
@@ -1142,6 +1142,28 @@ failed:
|
||||
}
|
||||
|
||||
#ifndef _WIN32_WCE
|
||||
|
||||
/* Helper routine for dll_is_loaded_by_basename.
|
||||
Return non-zero if the basename in ARG matches the DLL in INF. */
|
||||
|
||||
static int
|
||||
match_dll_by_basename (struct inferior_list_entry *inf, void *arg)
|
||||
{
|
||||
struct dll_info *iter = (void *) inf;
|
||||
const char *basename = arg;
|
||||
|
||||
return strcasecmp (lbasename (iter->name), basename) == 0;
|
||||
}
|
||||
|
||||
/* Return non-zero if the DLL specified by BASENAME is loaded. */
|
||||
|
||||
static int
|
||||
dll_is_loaded_by_basename (const char *basename)
|
||||
{
|
||||
return find_inferior (&all_dlls, match_dll_by_basename,
|
||||
(void *) basename) != NULL;
|
||||
}
|
||||
|
||||
/* On certain versions of Windows, the information about ntdll.dll
|
||||
is not available yet at the time we get the LOAD_DLL_DEBUG_EVENT,
|
||||
thus preventing us from reporting this DLL as an SO. This has been
|
||||
@@ -1158,20 +1180,14 @@ failed:
|
||||
static void
|
||||
win32_ensure_ntdll_loaded (void)
|
||||
{
|
||||
struct inferior_list_entry *dll_e;
|
||||
size_t i;
|
||||
HMODULE dh_buf[1];
|
||||
HMODULE *DllHandle = dh_buf;
|
||||
DWORD cbNeeded;
|
||||
BOOL ok;
|
||||
|
||||
for (dll_e = all_dlls.head; dll_e != NULL; dll_e = dll_e->next)
|
||||
{
|
||||
struct dll_info *dll = (struct dll_info *) dll_e;
|
||||
|
||||
if (strcasecmp (lbasename (dll->name), "ntdll.dll") == 0)
|
||||
return;
|
||||
}
|
||||
if (dll_is_loaded_by_basename ("ntdll.dll"))
|
||||
return;
|
||||
|
||||
if (!load_psapi ())
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user