From: Pedro Alves <pedro_alves@portugalmail.pt>
To: gdb-patches@sourceware.org
Subject: Re: Support of gdb for Windows 64 native systems
Date: Tue, 16 Oct 2007 00:18:00 -0000 [thread overview]
Message-ID: <4713F838.9050104@portugalmail.pt> (raw)
In-Reply-To: <20071015185451.GA3934@caradoc.them.org>
[-- Attachment #1: Type: text/plain, Size: 559 bytes --]
On Mon, Oct 15, 2007 at 02:45:25PM -0400, Christopher Faylor wrote:
> I just don't see why it should care about Cygwin. Why complicate the
> code with special case operations for cygwin when there is already a
> cygwin port? I doubt that this version of gdb would correctly translate
> cygwin paths built into the executable so it seems like it would just
> be a basically unused feature.
You convinced me.
Following your remark:
>There should be no cygwin accommodations in a pure windows port of gdb.
How about the attached?
Cheers,
Pedro Alves
[-- Attachment #2: mingw.diff --]
[-- Type: text/x-diff, Size: 9620 bytes --]
2007-10-14 Pedro Alves <pedro_alves@portugalmail.pt>
* config/i386/mingw.mh, config/i386/mingw.mt: New files.
* configure.tgt (i[34567]86-*-mingw32*): Set gdb_target = mingw.
* win32-nat.c: Only include cygwin.h on Cygwin host. Don't
include procfs.h.
(cygwin_load_start, cygwin_load_end, cygwin_exceptions): Disable
if not building for Cygwin.
(win32_make_so, handle_output_debug_string, handle_exception)
(do_initial_win32_stuff): Wrap Cygwin specific code in __CYGWIN__.
(win32_attach): Only fallback to Cygwin pids on Cygwin.
(win32_pid_to_exec_file): Disable Cygwin specific code.
(win32_create_inferior): Disable starting the inferior through a
shell, environment var processing and tty handling if not building
on Cygwin.
(cygwin_pid_to_str): Rename to ...
(win32_pid_to_str): ... this.
(init_win32_ops): Update use of win32_pid_to_str. Disable "shell"
and "cygwin-exceptions" commands if not building on Cygwin.
---
gdb/config/i386/mingw.mh | 4 +++
gdb/config/i386/mingw.mt | 3 ++
gdb/configure.tgt | 2 -
gdb/win32-nat.c | 52 +++++++++++++++++++++++++++++++++++++----------
4 files changed, 49 insertions(+), 12 deletions(-)
Index: src/gdb/config/i386/mingw.mh
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/config/i386/mingw.mh 2007-10-15 00:40:58.000000000 +0100
@@ -0,0 +1,4 @@
+MH_CFLAGS=
+NATDEPFILES= i386-nat.o win32-nat.o
+NAT_FILE=nm-cygwin.h
+XM_CLIBS=
Index: src/gdb/config/i386/mingw.mt
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
+++ src/gdb/config/i386/mingw.mt 2007-10-15 00:40:58.000000000 +0100
@@ -0,0 +1,3 @@
+# Target: Intel 386 run win32
+TDEPFILES= i386-tdep.o i386-cygwin-tdep.o i387-tdep.o \
+ solib-target.o corelow.o
Index: src/gdb/configure.tgt
===================================================================
--- src.orig/gdb/configure.tgt 2007-10-15 00:40:12.000000000 +0100
+++ src/gdb/configure.tgt 2007-10-15 00:40:58.000000000 +0100
@@ -120,7 +120,7 @@ i[34567]86-*-gnu*) gdb_target=i386gnu ;;
i[34567]86-*-cygwin*) gdb_target=cygwin
build_gdbserver=yes
;;
-i[34567]86-*-mingw32*) gdb_target=i386
+i[34567]86-*-mingw32*) gdb_target=mingw
build_gdbserver=yes
;;
i[34567]86-*-*) gdb_target=i386 ;;
Index: src/gdb/win32-nat.c
===================================================================
--- src.orig/gdb/win32-nat.c 2007-10-15 00:40:12.000000000 +0100
+++ src/gdb/win32-nat.c 2007-10-15 23:51:48.000000000 +0100
@@ -22,8 +22,6 @@
/* Originally by Steve Chamberlain, sac@cygnus.com */
-/* We assume we're being built with and will be used for cygwin. */
-
#include "defs.h"
#include "frame.h" /* required by inferior.h */
#include "inferior.h"
@@ -40,7 +38,9 @@
#include <stdlib.h>
#include <windows.h>
#include <imagehlp.h>
+#ifdef __CYGWIN__
#include <sys/cygwin.h>
+#endif
#include <signal.h>
#include "buildsym.h"
@@ -64,9 +64,11 @@
static struct target_ops win32_ops;
+#ifdef __CYGWIN__
/* The starting and ending address of the cygwin1.dll text segment. */
static bfd_vma cygwin_load_start;
static bfd_vma cygwin_load_end;
+#endif
static int have_saved_context; /* True if we've saved context from a cygwin signal. */
static CONTEXT saved_context; /* Containes the saved context from a cygwin signal. */
@@ -81,7 +83,6 @@ enum
CONTEXT_DEBUGGER = (CONTEXT_FULL | CONTEXT_FLOATING_POINT)
};
#endif
-#include <sys/procfs.h>
#include <psapi.h>
#define CONTEXT_DEBUGGER_DR CONTEXT_DEBUGGER | CONTEXT_DEBUG_REGISTERS \
@@ -142,7 +143,9 @@ static int saw_create;
/* User options. */
static int new_console = 0;
+#ifdef __CYGWIN__
static int cygwin_exceptions = 0;
+#endif
static int new_group = 1;
static int debug_exec = 0; /* show execution */
static int debug_events = 0; /* show events from kernel */
@@ -637,9 +640,11 @@ win32_make_so (const char *name, DWORD l
so = XZALLOC (struct so_list);
so->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info));
so->lm_info->load_addr = load_addr;
- cygwin_conv_to_posix_path (buf, so->so_name);
strcpy (so->so_original_name, name);
-
+#ifndef __CYGWIN__
+ strcpy (so->so_name, buf);
+#else
+ cygwin_conv_to_posix_path (buf, so->so_name);
/* Record cygwin1.dll .text start/end. */
p = strchr (so->so_name, '\0') - (sizeof ("/cygwin1.dll") - 1);
if (p >= so->so_name && strcasecmp (p, "/cygwin1.dll") == 0)
@@ -670,6 +675,7 @@ win32_make_so (const char *name, DWORD l
bfd_close (abfd);
}
+#endif
return so;
}
@@ -819,7 +825,9 @@ handle_output_debug_string (struct targe
/* nothing to do */;
else if (strncmp (s, _CYGWIN_SIGNAL_STRING, sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0)
{
+#ifdef __CYGWIN__
if (strncmp (s, "cYg", 3) != 0)
+#endif
warning (("%s"), s);
}
#ifdef __COPY_CONTEXT_SIZE
@@ -997,6 +1005,7 @@ handle_exception (struct target_waitstat
case EXCEPTION_ACCESS_VIOLATION:
DEBUG_EXCEPTION_SIMPLE ("EXCEPTION_ACCESS_VIOLATION");
ourstatus->value.sig = TARGET_SIGNAL_SEGV;
+#ifdef __CYGWIN__
{
/* See if the access violation happened within the cygwin DLL itself. Cygwin uses
a kind of exception handling to deal with passed-in invalid addresses. gdb
@@ -1011,6 +1020,7 @@ handle_exception (struct target_waitstat
&& strncmp (fn, "KERNEL32!IsBad", strlen ("KERNEL32!IsBad")) == 0))
return 0;
}
+#endif
break;
case STATUS_STACK_OVERFLOW:
DEBUG_EXCEPTION_SIMPLE ("STATUS_STACK_OVERFLOW");
@@ -1472,7 +1482,9 @@ do_initial_win32_stuff (DWORD pid)
debug_registers_used = 0;
for (i = 0; i < sizeof (dr) / sizeof (dr[0]); i++)
dr[i] = 0;
+#ifdef __CYGWIN__
cygwin_load_start = cygwin_load_end = 0;
+#endif
current_event.dwProcessId = pid;
memset (¤t_event, 0, sizeof (current_event));
push_target (&win32_ops);
@@ -1625,6 +1637,7 @@ win32_attach (char *args, int from_tty)
ok = DebugActiveProcess (pid);
saw_create = 0;
+#ifdef __CYGWIN__
if (!ok)
{
/* Try fall back to Cygwin pid */
@@ -1632,10 +1645,11 @@ win32_attach (char *args, int from_tty)
if (pid > 0)
ok = DebugActiveProcess (pid);
+ }
+#endif
- if (!ok)
- error (_("Can't attach to process."));
- }
+ if (!ok)
+ error (_("Can't attach to process."));
if (has_detach_ability ())
DebugSetProcessKillOnExit (FALSE);
@@ -1697,10 +1711,12 @@ win32_pid_to_exec_file (int pid)
/* Try to find the process path using the Cygwin internal process list
pid isn't a valid pid, unfortunately. Use current_event.dwProcessId
instead. */
- /* TODO: Also find native Windows processes using CW_GETPINFO_FULL. */
static char path[MAX_PATH + 1];
char *path_ptr = NULL;
+
+#ifdef __CYGWIN__
+ /* TODO: Also find native Windows processes using CW_GETPINFO_FULL. */
int cpid;
struct external_pinfo *pinfo;
@@ -1718,6 +1734,8 @@ win32_pid_to_exec_file (int pid)
}
}
cygwin_internal (CW_UNLOCK_PINFO);
+#endif
+
return path_ptr;
}
@@ -1764,6 +1782,7 @@ win32_create_inferior (char *exec_file,
memset (&si, 0, sizeof (si));
si.cb = sizeof (si);
+#ifdef __CYGWIN__
if (!useshell)
{
flags = DEBUG_ONLY_THIS_PROCESS;
@@ -1784,6 +1803,10 @@ win32_create_inferior (char *exec_file,
toexec = shell;
flags = DEBUG_PROCESS;
}
+#else
+ toexec = exec_file;
+ flags = DEBUG_ONLY_THIS_PROCESS;
+#endif
if (new_group)
flags |= CREATE_NEW_PROCESS_GROUP;
@@ -1798,6 +1821,7 @@ win32_create_inferior (char *exec_file,
strcat (args, " ");
strcat (args, allargs);
+#ifdef __CYGWIN__
/* Prepare the environment vars for CreateProcess. */
cygwin_internal (CW_SYNC_WINENV);
@@ -1821,6 +1845,7 @@ win32_create_inferior (char *exec_file,
dup2 (tty, 2);
}
}
+#endif
win32_init_thread_list ();
ret = CreateProcess (0,
@@ -1833,6 +1858,8 @@ win32_create_inferior (char *exec_file,
NULL, /* current directory */
&si,
&pi);
+
+#ifdef __CYGWIN__
if (tty >= 0)
{
close (tty);
@@ -1843,6 +1870,7 @@ win32_create_inferior (char *exec_file,
close (ostdout);
close (ostderr);
}
+#endif
if (!ret)
error (_("Error creating process %s, (error %d)."),
@@ -1951,7 +1979,7 @@ win32_close (int x)
/* Convert pid to printable format. */
static char *
-cygwin_pid_to_str (ptid_t ptid)
+win32_pid_to_str (ptid_t ptid)
{
static char buf[80];
int pid = PIDGET (ptid);
@@ -2055,7 +2083,7 @@ init_win32_ops (void)
win32_ops.to_mourn_inferior = win32_mourn_inferior;
win32_ops.to_can_run = win32_can_run;
win32_ops.to_thread_alive = win32_win32_thread_alive;
- win32_ops.to_pid_to_str = cygwin_pid_to_str;
+ win32_ops.to_pid_to_str = win32_pid_to_str;
win32_ops.to_stop = win32_stop;
win32_ops.to_stratum = process_stratum;
win32_ops.to_has_all_memory = 1;
@@ -2086,6 +2114,7 @@ _initialize_win32_nat (void)
add_com_alias ("sharedlibrary", "dll-symbols", class_alias, 1);
+#ifdef __CYGWIN__
add_setshow_boolean_cmd ("shell", class_support, &useshell, _("\
Set use of shell to start subprocess."), _("\
Show use of shell to start subprocess."), NULL,
@@ -2099,6 +2128,7 @@ Show whether gdb breaks on exceptions in
NULL,
NULL, /* FIXME: i18n: */
&setlist, &showlist);
+#endif
add_setshow_boolean_cmd ("new-console", class_support, &new_console, _("\
Set creation of new console when creating child process."), _("\
next prev parent reply other threads:[~2007-10-15 23:32 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <uprzkkrf7.fsf@gnu.org>
[not found] ` <20071012222842.GD21800@adacore.com>
[not found] ` <20071013024116.GB29152@adacore.com>
[not found] ` <uk5prl27s.fsf@gnu.org>
[not found] ` <20071013154715.GE29152@adacore.com>
[not found] ` <4711021C.8010805@portugalmail.pt>
[not found] ` <20071013205105.GA13789@adacore.com>
[not found] ` <47114BB7.1000501@portugalmail.pt>
[not found] ` <20071014051622.GC13789@adacore.com>
[not found] ` <471200C5.6050609@portugalmail.pt>
2007-10-14 18:03 ` Christopher Faylor
2007-10-14 19:55 ` Pedro Alves
2007-10-14 22:22 ` Christopher Faylor
2007-10-14 23:14 ` Daniel Jacobowitz
2007-10-15 18:54 ` Christopher Faylor
2007-10-15 19:19 ` Daniel Jacobowitz
2007-10-16 0:18 ` Pedro Alves [this message]
2007-10-16 4:21 ` Eli Zaretskii
2007-10-16 6:40 ` Christopher Faylor
2007-10-16 11:57 ` Pedro Alves
2007-10-16 12:41 ` Eli Zaretskii
2007-10-16 14:35 ` Christopher Faylor
2007-10-16 14:41 ` Pedro Alves
2007-10-16 15:56 ` Daniel Jacobowitz
2007-10-16 16:13 ` Christopher Faylor
2007-10-16 16:16 ` Eli Zaretskii
2007-10-16 18:23 ` Joel Brobecker
2007-10-16 18:57 ` Ulrich Weigand
2007-10-17 19:47 ` Pedro Alves
2007-10-17 22:00 ` Joel Brobecker
2007-10-18 4:06 ` Pedro Alves
2007-10-18 4:16 ` Eli Zaretskii
2007-10-18 10:07 ` Joel Brobecker
2007-10-18 20:20 ` Eli Zaretskii
2007-10-19 11:48 ` Joel Brobecker
2007-10-19 12:09 ` Daniel Jacobowitz
2007-10-19 12:27 ` Eli Zaretskii
2007-10-16 20:29 ` Pedro Alves
2007-10-14 23:29 ` Pedro Alves
2007-10-15 18:45 ` Christopher Faylor
2007-10-15 23:32 ` Pedro Alves
2007-10-14 21:16 ` Joel Brobecker
2007-10-14 22:22 ` Christopher Faylor
2007-10-15 8:58 ` Pedro Alves
2007-10-15 18:39 ` Christopher Faylor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4713F838.9050104@portugalmail.pt \
--to=pedro_alves@portugalmail.pt \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox