aboutsummaryrefslogtreecommitdiff
path: root/gdbserver
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-07-20 12:46:08 -0600
committerTom Tromey <tromey@adacore.com>2022-08-16 08:04:37 -0600
commit02d04eac24f497e34ac9869bac5bfb1e044a6b62 (patch)
tree5dbf104d58fe1abec6fe1338fb823c78a443de06 /gdbserver
parentec29a63c80602056bfc8533d230394d0db14b982 (diff)
downloadgdb-02d04eac24f497e34ac9869bac5bfb1e044a6b62.zip
gdb-02d04eac24f497e34ac9869bac5bfb1e044a6b62.tar.gz
gdb-02d04eac24f497e34ac9869bac5bfb1e044a6b62.tar.bz2
Use strwinerror in gdb/windows-nat.c
When working on windows-nat.c, it's useful to see an error message in addition to the error number given by GetLastError. This patch moves strwinerror from gdbserver to gdbsupport, and then updates windows-nat.c to use it. A couple of minor changes to strwinerror (constify the return type and use the ARRAY_SIZE macro) are also included.
Diffstat (limited to 'gdbserver')
-rw-r--r--gdbserver/win32-low.cc59
-rw-r--r--gdbserver/win32-low.h11
2 files changed, 0 insertions, 70 deletions
diff --git a/gdbserver/win32-low.cc b/gdbserver/win32-low.cc
index 2722407..5e2c028 100644
--- a/gdbserver/win32-low.cc
+++ b/gdbserver/win32-low.cc
@@ -61,10 +61,6 @@ gdbserver_windows_process windows_process;
#define _T(x) TEXT (x)
#endif
-#ifndef COUNTOF
-#define COUNTOF(STR) (sizeof (STR) / sizeof ((STR)[0]))
-#endif
-
int using_threads = 1;
const struct target_desc *win32_tdesc;
@@ -483,61 +479,6 @@ child_store_inferior_registers (struct regcache *regcache, int r)
(*the_low_target.store_inferior_register) (regcache, th, regno);
}
-/* Map the Windows error number in ERROR to a locale-dependent error
- message string and return a pointer to it. Typically, the values
- for ERROR come from GetLastError.
-
- The string pointed to shall not be modified by the application,
- but may be overwritten by a subsequent call to strwinerror
-
- The strwinerror function does not change the current setting
- of GetLastError. */
-
-char *
-strwinerror (DWORD error)
-{
- static char buf[1024];
- TCHAR *msgbuf;
- DWORD lasterr = GetLastError ();
- DWORD chars = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM
- | FORMAT_MESSAGE_ALLOCATE_BUFFER,
- NULL,
- error,
- 0, /* Default language */
- (LPTSTR) &msgbuf,
- 0,
- NULL);
- if (chars != 0)
- {
- /* If there is an \r\n appended, zap it. */
- if (chars >= 2
- && msgbuf[chars - 2] == '\r'
- && msgbuf[chars - 1] == '\n')
- {
- chars -= 2;
- msgbuf[chars] = 0;
- }
-
- if (chars > ((COUNTOF (buf)) - 1))
- {
- chars = COUNTOF (buf) - 1;
- msgbuf [chars] = 0;
- }
-
-#ifdef UNICODE
- wcstombs (buf, msgbuf, chars + 1);
-#else
- strncpy (buf, msgbuf, chars + 1);
-#endif
- LocalFree (msgbuf);
- }
- else
- sprintf (buf, "unknown win32 error (%u)", (unsigned) error);
-
- SetLastError (lasterr);
- return buf;
-}
-
static BOOL
create_process (const char *program, char *args,
DWORD flags, PROCESS_INFORMATION *pi)
diff --git a/gdbserver/win32-low.h b/gdbserver/win32-low.h
index 58bb105..d7bb76b 100644
--- a/gdbserver/win32-low.h
+++ b/gdbserver/win32-low.h
@@ -211,15 +211,4 @@ extern gdbserver_windows_process windows_process;
/* Retrieve the context for this thread, if not already retrieved. */
extern void win32_require_context (windows_nat::windows_thread_info *th);
-/* Map the Windows error number in ERROR to a locale-dependent error
- message string and return a pointer to it. Typically, the values
- for ERROR come from GetLastError.
-
- The string pointed to shall not be modified by the application,
- but may be overwritten by a subsequent call to strwinerror
-
- The strwinerror function does not change the current setting
- of GetLastError. */
-extern char * strwinerror (DWORD error);
-
#endif /* GDBSERVER_WIN32_LOW_H */