aboutsummaryrefslogtreecommitdiff
path: root/gdbserver/win32-low.cc
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2020-04-08 14:33:35 -0600
committerTom Tromey <tromey@adacore.com>2020-04-08 14:47:58 -0600
commit9d8679cc712d4c31d218cc141fe700d8e6394964 (patch)
tree41c6b2c0658250425f1bbd76aa5392ff7e38433d /gdbserver/win32-low.cc
parent28688adf8f883fdd8b642a446ec5578236e84b1e (diff)
downloadgdb-9d8679cc712d4c31d218cc141fe700d8e6394964.zip
gdb-9d8679cc712d4c31d218cc141fe700d8e6394964.tar.gz
gdb-9d8679cc712d4c31d218cc141fe700d8e6394964.tar.bz2
Share get_image_name between gdb and gdbserver
This moves get_image_name to nat/windows-nat.c so that it can be shared between gdb and gdbserver. gdb/ChangeLog 2020-04-08 Tom Tromey <tromey@adacore.com> * windows-nat.c (get_image_name): Move to nat/windows-nat.c. (handle_load_dll): Update. * nat/windows-nat.c (get_image_name): Move from windows-nat.c. gdbserver/ChangeLog 2020-04-08 Tom Tromey <tromey@adacore.com> * win32-low.c (get_image_name): Remove. (handle_load_dll): Update.
Diffstat (limited to 'gdbserver/win32-low.cc')
-rw-r--r--gdbserver/win32-low.cc51
1 files changed, 1 insertions, 50 deletions
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 1e86b3b..810896e 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -1031,55 +1031,6 @@ win32_add_one_solib (const char *name, CORE_ADDR load_addr)
loaded_dll (buf2, load_addr);
}
-static char *
-get_image_name (HANDLE h, void *address, int unicode)
-{
- static char buf[(2 * MAX_PATH) + 1];
- DWORD size = unicode ? sizeof (WCHAR) : sizeof (char);
- char *address_ptr;
- int len = 0;
- char b[2];
- SIZE_T done;
-
- /* Attempt to read the name of the dll that was detected.
- This is documented to work only when actively debugging
- a program. It will not work for attached processes. */
- if (address == NULL)
- return NULL;
-
-#ifdef _WIN32_WCE
- /* Windows CE reports the address of the image name,
- instead of an address of a pointer into the image name. */
- address_ptr = address;
-#else
- /* See if we could read the address of a string, and that the
- address isn't null. */
- if (!ReadProcessMemory (h, address, &address_ptr,
- sizeof (address_ptr), &done)
- || done != sizeof (address_ptr)
- || !address_ptr)
- return NULL;
-#endif
-
- /* Find the length of the string */
- while (ReadProcessMemory (h, address_ptr + len++ * size, &b, size, &done)
- && (b[0] != 0 || b[size - 1] != 0) && done == size)
- continue;
-
- if (!unicode)
- ReadProcessMemory (h, address_ptr, buf, len, &done);
- else
- {
- WCHAR *unicode_address = XALLOCAVEC (WCHAR, len);
- ReadProcessMemory (h, address_ptr, unicode_address, len * sizeof (WCHAR),
- &done);
-
- WideCharToMultiByte (CP_ACP, 0, unicode_address, len, buf, len, 0, 0);
- }
-
- return buf;
-}
-
typedef BOOL (WINAPI *winapi_EnumProcessModules) (HANDLE, HMODULE *,
DWORD, LPDWORD);
typedef BOOL (WINAPI *winapi_GetModuleInformation) (HANDLE, HMODULE,
@@ -1188,7 +1139,7 @@ static void
handle_load_dll (void)
{
LOAD_DLL_DEBUG_INFO *event = &current_event.u.LoadDll;
- char *dll_name;
+ const char *dll_name;
dll_name = get_image_name (current_process_handle,
event->lpImageName, event->fUnicode);