/* Target-vector operations for controlling windows child processes, for GDB.
- Copyright (C) 1995-2018 Free Software Foundation, Inc.
+ Copyright (C) 1995-2019 Free Software Foundation, Inc.
Contributed by Cygnus Solutions, A Red Hat Company.
#endif
#include <algorithm>
-#include "buildsym.h"
+#include "buildsym-legacy.h"
#include "filenames.h"
#include "symfile.h"
#include "objfiles.h"
#include "complaints.h"
#include "inf-child.h"
#include "gdb_tilde_expand.h"
+#include "common/pathstuff.h"
#define AdjustTokenPrivileges dyn_AdjustTokenPrivileges
#define DebugActiveProcessStop dyn_DebugActiveProcessStop
static int have_saved_context; /* True if we've saved context from a
cygwin signal. */
+#ifdef __CYGWIN__
static CONTEXT saved_context; /* Containes the saved context from a
cygwin signal. */
+#endif
/* If we're not using the old Cygwin header file set, define the
following which never should have been in the generic Win32 API
a segment register or not. */
static segment_register_p_ftype *segment_register_p;
+/* See windows_nat_target::resume to understand why this is commented
+ out. */
+#if 0
/* This vector maps the target's idea of an exception (extracted
from the DEBUG_EVENT structure) to GDB's idea. */
struct xlate_exception
{
- int them;
+ DWORD them;
enum gdb_signal us;
};
-static const struct xlate_exception
- xlate[] =
+static const struct xlate_exception xlate[] =
{
{EXCEPTION_ACCESS_VIOLATION, GDB_SIGNAL_SEGV},
{STATUS_STACK_OVERFLOW, GDB_SIGNAL_SEGV},
{EXCEPTION_BREAKPOINT, GDB_SIGNAL_TRAP},
{DBG_CONTROL_C, GDB_SIGNAL_INT},
{EXCEPTION_SINGLE_STEP, GDB_SIGNAL_TRAP},
- {STATUS_FLOAT_DIVIDE_BY_ZERO, GDB_SIGNAL_FPE},
- {-1, GDB_SIGNAL_UNKNOWN}};
+ {STATUS_FLOAT_DIVIDE_BY_ZERO, GDB_SIGNAL_FPE}
+};
+#endif /* 0 */
struct windows_nat_target final : public x86_nat_target<inf_child_target>
{
windows_thread_info *th;
DWORD id;
- gdb_assert (ptid_get_tid (ptid) != 0);
+ gdb_assert (ptid.tid () != 0);
- id = ptid_get_tid (ptid);
+ id = ptid.tid ();
if ((th = thread_rec (id, FALSE)))
return th;
windows_thread_info *th;
DWORD id;
- gdb_assert (ptid_get_tid (ptid) != 0);
+ gdb_assert (ptid.tid () != 0);
- id = ptid_get_tid (ptid);
+ id = ptid.tid ();
if (info_verbose)
printf_unfiltered ("[Deleting %s]\n", target_pid_to_str (ptid));
void
windows_nat_target::fetch_registers (struct regcache *regcache, int r)
{
- DWORD pid = ptid_get_tid (regcache->ptid ());
+ DWORD pid = regcache->ptid ().tid ();
windows_thread_info *th = thread_rec (pid, TRUE);
/* Check if TH exists. Windows sometimes uses a non-existent
void
windows_nat_target::store_registers (struct regcache *regcache, int r)
{
- DWORD pid = ptid_get_tid (regcache->ptid ());
+ DWORD pid = regcache->ptid ().tid ();
windows_thread_info *th = thread_rec (pid, TRUE);
/* Check if TH exists. Windows sometimes uses a non-existent
static BOOL
windows_continue (DWORD continue_status, int id, int killed)
{
- int i;
windows_thread_info *th;
BOOL res;
DWORD continue_status = DBG_CONTINUE;
/* A specific PTID means `step only this thread id'. */
- int resume_all = ptid_equal (ptid, minus_one_ptid);
+ int resume_all = ptid == minus_one_ptid;
/* If we're continuing all threads, it's the current inferior that
should be handled specially. */
structure when passing the exception to the inferior.
Note that this seems possible in the exception handler itself. */
{
- int i;
- for (i = 0; xlate[i].them != -1; i++)
- if (xlate[i].us == sig)
+ for (const xlate_exception &x : xlate)
+ if (x.us == sig)
{
current_event.u.Exception.ExceptionRecord.ExceptionCode
- = xlate[i].them;
+ = x.them;
continue_status = DBG_EXCEPTION_NOT_HANDLED;
break;
}
last_sig = GDB_SIGNAL_0;
DEBUG_EXEC (("gdb: windows_resume (pid=%d, tid=%ld, step=%d, sig=%d);\n",
- ptid.pid (), ptid_get_tid (ptid), step, sig));
+ ptid.pid (), ptid.tid (), step, sig));
/* Get context for currently selected thread. */
- th = thread_rec (ptid_get_tid (inferior_ptid), FALSE);
+ th = thread_rec (inferior_ptid.tid (), FALSE);
if (th)
{
if (step)
if (resume_all)
windows_continue (continue_status, -1, 0);
else
- windows_continue (continue_status, ptid_get_tid (ptid), 0);
+ windows_continue (continue_status, ptid.tid (), 0);
}
/* Ctrl-C handler used when the inferior is not run in the same console. The
{
int pid = -1;
- target_terminal::ours ();
-
/* We loop when we get a non-standard exception rather than return
with a SPURIOUS because resume can try and step or modify things,
which needs a current_thread->h. But some of these exceptions mark
static void
windows_add_all_dlls (void)
{
- struct so_list *so;
HMODULE dummy_hmodule;
DWORD cb_needed;
HMODULE *hmodules;
{
int i;
struct inferior *inf;
- struct thread_info *tp;
last_sig = GDB_SIGNAL_0;
event_count = 0;
int tty;
int ostdin, ostdout, ostderr;
#else /* !__CYGWIN__ */
- char real_path[__PMAX];
char shell[__PMAX]; /* Path to shell */
const char *toexec;
char *args, *allargs_copy;
size_t args_len, allargs_len;
int fd_inp = -1, fd_out = -1, fd_err = -1;
HANDLE tty = INVALID_HANDLE_VALUE;
- HANDLE inf_stdin = INVALID_HANDLE_VALUE;
- HANDLE inf_stdout = INVALID_HANDLE_VALUE;
- HANDLE inf_stderr = INVALID_HANDLE_VALUE;
bool redirected = false;
char *w32env;
char *temp;
}
else
{
- sh = getenv ("SHELL");
- if (!sh)
- sh = "/bin/sh";
+ sh = get_shell ();
if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, sh, shell, __PMAX) < 0)
error (_("Error starting executable via shell: %d"), errno);
#ifdef __USEWIDE
if (tty >= 0)
{
- close (tty);
+ ::close (tty);
dup2 (ostdin, 0);
dup2 (ostdout, 1);
dup2 (ostderr, 2);
- close (ostdin);
- close (ostdout);
- close (ostderr);
+ ::close (ostdin);
+ ::close (ostdout);
+ ::close (ostderr);
}
#else /* !__CYGWIN__ */
allargs_len = strlen (allargs);
{
static char buf[80];
- if (ptid_get_tid (ptid) != 0)
+ if (ptid.tid () != 0)
{
snprintf (buf, sizeof (buf), "Thread %d.0x%lx",
- ptid.pid (), ptid_get_tid (ptid));
+ ptid.pid (), ptid.tid ());
return buf;
}
{
windows_thread_info *th;
- th = thread_rec (ptid_get_tid (ptid), 0);
+ th = thread_rec (ptid.tid (), 0);
if (th == NULL)
return false;
const char *
windows_nat_target::thread_name (struct thread_info *thr)
{
- return thread_rec (ptid_get_tid (thr->ptid), 0)->name;
+ return thread_rec (thr->ptid.tid (), 0)->name;
}
{
int tid;
- gdb_assert (ptid_get_tid (ptid) != 0);
- tid = ptid_get_tid (ptid);
+ gdb_assert (ptid.tid () != 0);
+ tid = ptid.tid ();
return WaitForSingleObject (thread_rec (tid, FALSE)->h, 0) != WAIT_OBJECT_0;
}