From: Christopher Faylor <cgf-use-the-mailinglist-please@sourceware.org>
To: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [RFA] windows: do not crash if inferior
Date: Wed, 20 Jan 2010 17:38:00 -0000 [thread overview]
Message-ID: <20100120173746.GA27289@ednor.casa.cgf.cx> (raw)
In-Reply-To: <20100120161549.GA24063@ednor.casa.cgf.cx>
On Wed, Jan 20, 2010 at 11:15:49AM -0500, Christopher Faylor wrote:
>On Tue, Jan 19, 2010 at 01:22:27PM +0400, Joel Brobecker wrote:
>>> 2010-01-13 gingold <gingold@adacore.com>
>>>
>>> * windows-nat.c (do_initial_windows_stuff): Call error() if the
>>> inferior doesn't exist anymore.
>>
>>Just some thoughts, as Chris usually reviews Windows patches...
>>
>>I don't see a "generic" way of dealing with this situation. So the type
>>of approach you took (returning early from do_initial_windows_stuff)
>>seems to be the only approach I can see. I was initially a little
>>reluctant about throwing an error: As far as I can tell from the code,
>>the debugger should have already printed an error message such as
>>"Inferior exited with code ..." (is that correct?) - and so an extra
>>"inferior exited early" message could be considered superfluous. However,
>>if you do not error-out now, core GDB will assume that target_create_inferior
>>succeeded and thus possibly do something unexpected as well.
>>
>>Bottom line - I cannot propose a better approach short of revamping
>>a bit the target_create_inferior routine to add error-handling,
>>I think the patch is fine.
>>
>>I would suggest a different wording, to explain that we were trying
>>to run the program when the error occured.
>>
>> error (_("cannot run program, inferior exited prematurely during startup"));
>
>Does inferior_thread really need the assert()? If not, we could jsut test
>tp for NULL.
>
>Otherwise, I agree with Joel's assessment.
Actually, how about something like this instead? I used the same wording as fork-child.c
after seeing Pedro's note.
cgf
Index: windows-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/windows-nat.c,v
retrieving revision 1.196.4.1
diff -d -u -r1.196.4.1 windows-nat.c
--- windows-nat.c 30 Sep 2009 07:40:10 -0000 1.196.4.1
+++ windows-nat.c 20 Jan 2010 17:35:47 -0000
@@ -41,6 +41,7 @@
#include <psapi.h>
#ifdef __CYGWIN__
#include <sys/cygwin.h>
+#include <cygwin/version.h>
#endif
#include <signal.h>
@@ -123,6 +128,8 @@
static uintptr_t dr[8];
static int debug_registers_changed;
static int debug_registers_used;
+
+static int windows_initialization_done;
#define DR6_CLEAR_VALUE 0xffff0ff0
/* The string sent by cygwin when it processes a signal.
@@ -1399,6 +1407,8 @@
(unsigned) current_event.dwProcessId,
(unsigned) current_event.dwThreadId,
"EXIT_PROCESS_DEBUG_EVENT"));
+ if (!windows_initialization_done)
+ error (_("During startup program exited with code 0x%x."), (unsigned int) current_event.u.ExitProcess.dwExitCode);
if (saw_create != 1)
break;
ourstatus->kind = TARGET_WAITKIND_EXITED;
@@ -1597,6 +1607,7 @@
terminal_init_inferior_with_pgrp (pid);
target_terminal_inferior ();
+ windows_initialization_done = 0;
inf->stop_soon = STOP_QUIETLY;
while (1)
{
@@ -1609,6 +1620,7 @@
break;
}
+ windows_initialization_done = 1;
inf->stop_soon = NO_STOP_QUIETLY;
stop_after_trap = 0;
return;
next prev parent reply other threads:[~2010-01-20 17:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-13 9:25 Tristan Gingold
2010-01-19 9:22 ` Joel Brobecker
2010-01-20 16:16 ` Christopher Faylor
2010-01-20 16:35 ` Pedro Alves
2010-01-20 17:38 ` Christopher Faylor [this message]
2010-01-20 18:57 ` Christopher Faylor
2010-01-20 19:12 ` Pedro Alves
2010-01-21 17:57 ` Christopher Faylor
2010-01-26 15:59 ` Tristan Gingold
2010-01-28 14:55 ` Christopher Faylor
2010-01-20 16:41 ` Pedro Alves
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=20100120173746.GA27289@ednor.casa.cgf.cx \
--to=cgf-use-the-mailinglist-please@sourceware.org \
--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