From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14828 invoked by alias); 8 Feb 2008 23:17:50 -0000 Received: (qmail 14820 invoked by uid 22791); 8 Feb 2008 23:17:48 -0000 X-Spam-Check-By: sourceware.org Received: from flagship.tchse.com (HELO flagship.tchse.com) (209.85.32.22) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Feb 2008 23:17:27 +0000 Received: from cpc2-port4-0-0-cust303.cos2.cable.ntl.com ([82.25.97.48] helo=[127.0.0.1]) by flagship.tchse.com with esmtpa (Exim 4.63) (envelope-from ) id 1JNcTF-0001aN-5c; Fri, 08 Feb 2008 18:17:25 -0500 Message-ID: <47ACE302.9030404@devkitpro.org> Date: Fri, 08 Feb 2008 23:17:00 -0000 From: Dave Murphy User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Mike Frysinger CC: insight@sourceware.org Subject: Re: MinGW patches for Insight References: <47AAC222.2080906@devkitpro.org> <47AC8FC4.8070204@devkitpro.org> <200802081304.01150.vapier@gentoo.org> In-Reply-To: <200802081304.01150.vapier@gentoo.org> Content-Type: multipart/mixed; boundary="------------090704040404040907030904" X-Antivirus: avast! (VPS 080208-0, 08/02/2008), Outbound message X-Antivirus-Status: Clean X-IsSubscribed: yes Mailing-List: contact insight-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: insight-owner@sourceware.org X-SW-Source: 2008-q1/txt/msg00016.txt.bz2 This is a multi-part message in MIME format. --------------090704040404040907030904 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 568 Mike Frysinger wrote: > On Friday 08 February 2008, Dave Murphy wrote: > >> I'm still not sure how best to format the changelog entries. Should I be >> sending a patchset for each directory where changes are made? >> > > you do it based upon the ChangeLog files that already exist. look at the file > you change, and then walk up directories until you hit the first ChangeLog > file. > Thanks for the advice Mike, much appreciated. Updated patch with suggested changes attached. I've submitted the ppc sim patch to the gdb patches list instead. Dave --------------090704040404040907030904 Content-Type: text/plain; name="insight-mingw.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="insight-mingw.patch" Content-length: 16085 2008-02-07 Dave Murphy * configure.ac :set tcl configdir to win under mingw * configure : regenerate gdb/gdbtk/generic/ 2008-02-07 Dave Murphy * gdbtk-cmds.c : guard with HAVE_SYS_IOCTL_H * gdbtk-hooks.c : ditto * gdbtk.c : ditto * gdbtk-interp.c : include under mingw32 (gdbtk_start_timer, gdbtk_stop_timer): remove timer calls under mingw (gdbtk_init): include windows specific commands under mingw without cygwin path commands gdb/gdbtk/library/ 2008-02-07 Dave Murphy * download.itb (Download::download_it) : check ide_cygwin_path exists before using on windows * interface.tcl (_open_file) : ditto * prefs.tcl : (pref_read) : ditto * session.tcl : ( _exe_name) : ditto * srctextwin.itb : (SrcTextWin::_mtime_changed, SrcTextWin::LoadFromCache) : ditto * targetselection.itb (TargetSelection::default_port) : default to /dev/com1 under cygwin, COM1 under mingw (TargetSelection::port_list) : use /dev/com under cygwin, COM under mingw tcl/win 2008-02-07 Dave Murphy * tclWin32Dll.c (TclpCheckStackSpace) : backport EXCEPTION_REGISTRATION code from TCL mainline Index: gdb/configure.ac =================================================================== RCS file: /cvs/src/src/gdb/configure.ac,v retrieving revision 1.64 diff -u -r1.64 configure.ac --- gdb/configure.ac 13 Jan 2008 12:23:05 -0000 1.64 +++ gdb/configure.ac 8 Feb 2008 20:41:52 -0000 @@ -1445,7 +1445,7 @@ AC_SUBST(WIN32LDAPP) case "${host}" in -*-*-cygwin*) +*-*-cygwin* | *-*-mingw* ) configdir="win" ;; *) Index: gdb/gdbtk/generic/gdbtk-cmds.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-cmds.c,v retrieving revision 1.97 diff -u -r1.97 gdbtk-cmds.c --- gdb/gdbtk/generic/gdbtk-cmds.c 21 Jun 2007 15:18:51 -0000 1.97 +++ gdb/gdbtk/generic/gdbtk-cmds.c 7 Feb 2008 03:43:06 -0000 @@ -57,7 +57,9 @@ #include #include +#ifdef HAVE_SYS_IOCTL_H #include +#endif #include #include Index: gdb/gdbtk/generic/gdbtk-hooks.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-hooks.c,v retrieving revision 1.41 diff -u -r1.41 gdbtk-hooks.c --- gdb/gdbtk/generic/gdbtk-hooks.c 23 Dec 2005 18:23:16 -0000 1.41 +++ gdb/gdbtk/generic/gdbtk-hooks.c 7 Feb 2008 03:43:19 -0000 @@ -51,7 +51,9 @@ #include #include +#ifdef HAVE_SYS_IOCTL_H #include +#endif #include #include "gdb_string.h" Index: gdb/gdbtk/generic/gdbtk-interp.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk-interp.c,v retrieving revision 1.8 diff -u -r1.8 gdbtk-interp.c --- gdb/gdbtk/generic/gdbtk-interp.c 23 Dec 2005 18:23:16 -0000 1.8 +++ gdb/gdbtk/generic/gdbtk-interp.c 8 Feb 2008 20:46:44 -0000 @@ -34,6 +34,12 @@ #include "tk.h" #include "gdbtk.h" +#ifdef __MINGW32__ +# define WIN32_LEAN_AND_MEAN +# include +#endif + + static void gdbtk_command_loop (void); static void hack_disable_interpreter_exec (char *, int); Index: gdb/gdbtk/generic/gdbtk.c =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/generic/gdbtk.c,v retrieving revision 1.45 diff -u -r1.45 gdbtk.c --- gdb/gdbtk/generic/gdbtk.c 1 Dec 2006 02:09:24 -0000 1.45 +++ gdb/gdbtk/generic/gdbtk.c 7 Feb 2008 06:23:48 -0000 @@ -49,7 +49,9 @@ #include #include +#ifdef HAVE_SYS_IOCTL_H #include +#endif #include #include @@ -63,6 +65,7 @@ extern void _initialize_gdbtk (void); +#ifndef __MINGW32__ /* For unix natives, we use a timer to periodically keep the gui alive. See comments before x_event. */ static sigset_t nullsigmask; @@ -74,6 +77,7 @@ { x_event (signo); } +#endif /* * This variable controls the interaction with an external editor. @@ -262,6 +266,7 @@ { /* first time called, set up all the structs */ first = 0; +#ifndef __MINGW32__ sigemptyset (&nullsigmask); act1.sa_handler = x_event_wrapper; @@ -281,14 +286,17 @@ it_off.it_interval.tv_usec = 0; it_off.it_value.tv_sec = 0; it_off.it_value.tv_usec = 0; +#endif } if (target_should_use_timer (¤t_target)) { if (!gdbtk_timer_going) { +#ifndef __MINGW32__ sigaction (SIGALRM, &act1, NULL); setitimer (ITIMER_REAL, &it_on, NULL); +#endif gdbtk_timer_going = 1; } } @@ -302,8 +310,10 @@ if (gdbtk_timer_going) { gdbtk_timer_going = 0; +#ifndef __MINGW32__ setitimer (ITIMER_REAL, &it_off, NULL); sigaction (SIGALRM, &act2, NULL); +#endif } return; } @@ -510,7 +520,7 @@ * These are the commands to do some Windows Specific stuff... */ -#ifdef __CYGWIN32__ +#ifdef __WIN32__ if (ide_create_messagebox_command (gdbtk_interp) != TCL_OK) error ("messagebox command initialization failed"); /* On Windows, create a sizebox widget command */ @@ -522,6 +532,8 @@ error ("windows print code initialization failed"); if (ide_create_win_grab_command (gdbtk_interp) != TCL_OK) error ("grab support command initialization failed"); +#endif +#ifdef __CYGWIN32__ /* Path conversion functions. */ if (ide_create_cygwin_path_command (gdbtk_interp) != TCL_OK) error ("cygwin path command initialization failed"); Index: gdb/gdbtk/library/download.itb =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/download.itb,v retrieving revision 1.11 diff -u -r1.11 download.itb --- gdb/gdbtk/library/download.itb 23 Dec 2005 18:26:50 -0000 1.11 +++ gdb/gdbtk/library/download.itb 6 Feb 2008 04:30:59 -0000 @@ -207,7 +207,7 @@ } } - if {[string compare $tcl_platform(platform) "windows"] == 0} { + if {[string compare $tcl_platform(platform) "windows"] == 0 && [llength [info commands ide_cygwin_path]]} { set f [ide_cygwin_path to_win32 $gdb_exe_name] } else { set f $gdb_exe_name Index: gdb/gdbtk/library/interface.tcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/interface.tcl,v retrieving revision 1.57 diff -u -r1.57 interface.tcl --- gdb/gdbtk/library/interface.tcl 23 Dec 2005 18:26:50 -0000 1.57 +++ gdb/gdbtk/library/interface.tcl 6 Feb 2008 04:32:56 -0000 @@ -962,7 +962,7 @@ } # Add the base dir for this file to the source search path. set root [file dirname $file] - if {$tcl_platform(platform) == "windows"} { + if {$tcl_platform(platform) == "windows" && [llength [info commands ide_cygwin_path]]} { set root [ide_cygwin_path to_posix $root] set file [ide_cygwin_path to_posix $file] } Index: gdb/gdbtk/library/prefs.tcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/prefs.tcl,v retrieving revision 1.34 diff -u -r1.34 prefs.tcl --- gdb/gdbtk/library/prefs.tcl 19 Sep 2006 18:39:38 -0000 1.34 +++ gdb/gdbtk/library/prefs.tcl 6 Feb 2008 04:33:48 -0000 @@ -35,7 +35,7 @@ global tcl_platform if {[info exists env(HOME)]} { - if {$tcl_platform(platform) == "windows"} { + if {$tcl_platform(platform) == "windows" && [llength [info commands ide_cygwin_path]]} { set home [ide_cygwin_path to_win32 $env(HOME)] } else { set home $env(HOME) Index: gdb/gdbtk/library/session.tcl =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/session.tcl,v retrieving revision 1.16 diff -u -r1.16 session.tcl --- gdb/gdbtk/library/session.tcl 23 Dec 2005 18:26:50 -0000 1.16 +++ gdb/gdbtk/library/session.tcl 7 Feb 2008 01:59:00 -0000 @@ -21,7 +21,7 @@ global tcl_platform # Get real directory. - if {[string compare $tcl_platform(platform) "windows"] == 0} { + if {[string compare $tcl_platform(platform) "windows"] == 0 && [llength [info commands ide_cygwin_path]]} { set path [ide_cygwin_path to_win32 $path] } set save [pwd] Index: gdb/gdbtk/library/srctextwin.itb =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/srctextwin.itb,v retrieving revision 1.42 diff -u -r1.42 srctextwin.itb --- gdb/gdbtk/library/srctextwin.itb 23 Dec 2005 18:26:50 -0000 1.42 +++ gdb/gdbtk/library/srctextwin.itb 7 Feb 2008 02:04:47 -0000 @@ -891,7 +891,7 @@ } elseif {$f == ""} { set r 1 } else { - if {[string compare $tcl_platform(platform) "windows"] == 0} { + if {[string compare $tcl_platform(platform) "windows"] == 0 && [llength [info commands ide_cygwin_path]]} { set f [ide_cygwin_path to_win32 $f] } if {[catch {file mtime $f} mtime]} { @@ -2715,7 +2715,7 @@ # out. if {$loadingSource} { - if {[string compare $tcl_platform(platform) "windows"] == 0} { + if {[string compare $tcl_platform(platform) "windows"] == 0 && [llength [info commands ide_cygwin_path]]} { set f [ide_cygwin_path to_win32 $name] } else { set f $name Index: gdb/gdbtk/library/targetselection.itb =================================================================== RCS file: /cvs/src/src/gdb/gdbtk/library/targetselection.itb,v retrieving revision 1.20 diff -u -r1.20 targetselection.itb --- gdb/gdbtk/library/targetselection.itb 1 Dec 2006 01:07:55 -0000 1.20 +++ gdb/gdbtk/library/targetselection.itb 7 Feb 2008 00:17:37 -0000 @@ -280,7 +280,13 @@ itcl::body TargetSelection::default_port {} { global tcl_platform switch -regexp $tcl_platform(os) { - Windows { set port com1 } + Windows { + if { [llength [info commands ide_cygwin_path]] } { + set port "/dev/com1" + } else { + set port "COM1" + } + } Linux { set port /dev/ttyS0 } SunOS { set port /dev/ttya } AIX { set port /dev/foo1 } @@ -873,6 +879,11 @@ # METHOD: port_list - return a list of valid ports for Windows # ------------------------------------------------------------------ itcl::body TargetSelection::port_list {} { + if { [llength [info commands ide_cygwin_path]] } { + set device "/dev/com" + } else { + set device "COM" + } set plist "" # Scan com1 - com8 trying to open each one. # If permission is denied that means it is in use, @@ -885,7 +896,7 @@ # Failed. Find out why. if {[string first "permission denied" $msg] != -1} { # Port is there, but busy right now. That's OK. - lappend plist /dev/com$i + lappend plist $device$i } elseif {$i > 4} { # if we've scanned the first 4 ports, then quit when we find no more set quit 1 @@ -893,7 +904,7 @@ } else { # We got it. Now close it and add to list. close $fd - lappend plist /dev/com$i + lappend plist $device$i } } return $plist Index: tcl/win/tclWin32Dll.c =================================================================== RCS file: /cvs/src/src/tcl/win/tclWin32Dll.c,v retrieving revision 1.11 diff -u -r1.11 tclWin32Dll.c --- tcl/win/tclWin32Dll.c 1 Dec 2006 20:35:55 -0000 1.11 +++ tcl/win/tclWin32Dll.c 7 Feb 2008 05:54:10 -0000 @@ -41,9 +41,21 @@ static int platformId; /* Running under NT, or 95/98? */ #ifdef HAVE_NO_SEH -static void *ESP; -static void *EBP; -#endif /* HAVE_NO_SEH */ +/* + * Unlike Borland and Microsoft, we don't register exception handlers by + * pushing registration records onto the runtime stack. Instead, we register + * them by creating an EXCEPTION_REGISTRATION within the activation record. + */ + +typedef struct EXCEPTION_REGISTRATION { + struct EXCEPTION_REGISTRATION *link; + EXCEPTION_DISPOSITION (*handler)( + struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); + void *ebp; + void *esp; + int status; +} EXCEPTION_REGISTRATION; +#endif /* * The following function tables are used to dispatch to either the @@ -358,65 +370,102 @@ int TclpCheckStackSpace() { + +#ifdef HAVE_NO_SEH + EXCEPTION_REGISTRATION registration; +#endif int retval = 0; /* - * We can recurse only if there is at least TCL_WIN_STACK_THRESHOLD - * bytes of stack space left. alloca() is cheap on windows; basically - * it just subtracts from the stack pointer causing the OS to throw an - * exception if the stack pointer is set below the bottom of the stack. + * We can recurse only if there is at least TCL_WIN_STACK_THRESHOLD bytes + * of stack space left. alloca() is cheap on windows; basically it just + * subtracts from the stack pointer causing the OS to throw an exception + * if the stack pointer is set below the bottom of the stack. */ #ifdef HAVE_NO_SEH __asm__ __volatile__ ( - "movl %esp, _ESP" "\n\t" - "movl %ebp, _EBP"); - __asm__ __volatile__ ( - "pushl $__except_checkstackspace_handler" "\n\t" - "pushl %fs:0" "\n\t" - "mov %esp, %fs:0"); -#else + /* + * Construct an EXCEPTION_REGISTRATION to protect the call to __alloca + */ + + "leal %[registration], %%edx" "\n\t" + "movl %%fs:0, %%eax" "\n\t" + "movl %%eax, 0x0(%%edx)" "\n\t" /* link */ + "leal 1f, %%eax" "\n\t" + "movl %%eax, 0x4(%%edx)" "\n\t" /* handler */ + "movl %%ebp, 0x8(%%edx)" "\n\t" /* ebp */ + "movl %%esp, 0xc(%%edx)" "\n\t" /* esp */ + "movl %[error], 0x10(%%edx)" "\n\t" /* status */ + + /* + * Link the EXCEPTION_REGISTRATION on the chain + */ + + "movl %%edx, %%fs:0" "\n\t" + + /* + * Attempt a call to __alloca, to determine whether there's sufficient + * memory to be had. + */ + + "movl %[size], %%eax" "\n\t" + "pushl %%eax" "\n\t" + "call __alloca" "\n\t" + + /* + * Come here on a normal exit. Recover the EXCEPTION_REGISTRATION and + * store a TCL_OK status + */ + + "movl %%fs:0, %%edx" "\n\t" + "movl %[ok], %%eax" "\n\t" + "movl %%eax, 0x10(%%edx)" "\n\t" + "jmp 2f" "\n" + + /* + * Come here on an exception. Get the EXCEPTION_REGISTRATION that we + * previously put on the chain. + */ + + "1:" "\t" + "movl %%fs:0, %%edx" "\n\t" + "movl 0x8(%%edx), %%edx" "\n\t" + + /* + * Come here however we exited. Restore context from the + * EXCEPTION_REGISTRATION in case the stack is unbalanced. + */ + + "2:" "\t" + "movl 0xc(%%edx), %%esp" "\n\t" + "movl 0x8(%%edx), %%ebp" "\n\t" + "movl 0x0(%%edx), %%eax" "\n\t" + "movl %%eax, %%fs:0" "\n\t" + + : + /* No outputs */ + : + [registration] "m" (registration), + [ok] "i" (TCL_OK), + [error] "i" (TCL_ERROR), + [size] "i" (TCL_WIN_STACK_THRESHOLD) + : + "%eax", "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory" + ); + retval = (registration.status == TCL_OK); + +#else /* !HAVE_NO_SEH */ __try { -#endif /* HAVE_NO_SEH */ alloca(TCL_WIN_STACK_THRESHOLD); retval = 1; -#ifdef HAVE_NO_SEH - __asm__ __volatile__ ( - "jmp checkstackspace_pop" "\n" - "checkstackspace_reentry:" "\n\t" - "movl _ESP, %esp" "\n\t" - "movl _EBP, %ebp"); - - __asm__ __volatile__ ( - "checkstackspace_pop:" "\n\t" - "mov (%esp), %eax" "\n\t" - "mov %eax, %fs:0" "\n\t" - "add $8, %esp"); -#else } __except (EXCEPTION_EXECUTE_HANDLER) {} #endif /* HAVE_NO_SEH */ - /* - * Avoid using control flow statements in the SEH guarded block! - */ return retval; } -#ifdef HAVE_NO_SEH -static -__attribute__ ((cdecl,used)) -EXCEPTION_DISPOSITION -_except_checkstackspace_handler( - struct _EXCEPTION_RECORD *ExceptionRecord, - void *EstablisherFrame, - struct _CONTEXT *ContextRecord, - void *DispatcherContext) -{ - __asm__ __volatile__ ( - "jmp checkstackspace_reentry"); - return 0; /* Function does not return */ -} -#endif /* HAVE_NO_SEH */ + /* *---------------------------------------------------------------------- --------------090704040404040907030904--