From: Danny Backx <danny.backx@scarlet.be>
To: Pedro Alves <pedro@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: Patch : gdbserver get_image_name on CE
Date: Wed, 01 Jul 2009 19:31:00 -0000 [thread overview]
Message-ID: <1246476684.15871.273.camel@pavilion> (raw)
In-Reply-To: <200906302258.00604.pedro@codesourcery.com>
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On Tue, 2009-06-30 at 22:58 +0100, Pedro Alves wrote:
> On Tuesday 30 June 2009 22:07:19, Danny Backx wrote:
> >
> > > Is the rest of my patch acceptable or are there things I need to
> > > address ?
> > >
>
> Did you get to confirm what really that ERROR_PIPE_NOT_CONNECTED
> is about?
>
> http://sourceware.org/ml/gdb-patches/2009-06/msg00373.html
>
> Could you post an updated, cleaned up patch, without any extra
> unnecessary bits removed, along with change log entry, using
> 'cvs diff -up'?
Attached. Comments, as always, welcome.
Danny
--
Danny Backx ; danny.backx - at - scarlet.be ; http://danny.backx.info
[-- Attachment #2: 1 --]
[-- Type: text/plain, Size: 5476 bytes --]
2009-07-01 Danny Backx <dannybackx@users.sourceforge.net>
* win32-i386-low.c (i386_get_thread_context): Avoid failure by
calling GetThreadContext with flags that don't work on every
processor. Fall back to querying less registers if that happens.
* win32-i386-low.c (the_low_target, i386_wince_breakpoint) : Implement
breakpoints.
* win32-low.c (get_image_name): Don't rely on return value of
ReadProcessMemory. Comment where some of the code still relies on
sizeof(WCHAR) == 2.
* win32-low.c (get_child_debug_event): Detect and work around a known
case where CreateProcess reports success but the inferior dies
immediately.
Index: win32-i386-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/win32-i386-low.c,v
retrieving revision 1.14
diff -u -u -p -r1.14 win32-i386-low.c
--- win32-i386-low.c 3 Jan 2009 05:57:57 -0000 1.14
+++ win32-i386-low.c 1 Jul 2009 19:28:15 -0000
@@ -39,16 +39,36 @@ i386_initial_stuff (void)
debug_registers_used = 0;
}
+/*
+ * According to Mike Stall's .net debugging blog
+ * (http://blogs.msdn.com/jmstall/archive/2005/01/18/355697.aspx)
+ * the CONTEXT_EXTENDED_REGISTERS flag must be omitted if hardware doesn't
+ * support it. So I guess the only reasonable thing to do is just try.
+ */
static void
i386_get_thread_context (win32_thread_info *th, DEBUG_EVENT* current_event)
{
- th->context.ContextFlags = \
- CONTEXT_FULL | \
- CONTEXT_FLOATING_POINT | \
- CONTEXT_EXTENDED_REGISTERS | \
+ /* try all flags */
+ th->context.ContextFlags =
+ CONTEXT_FULL |
+ CONTEXT_FLOATING_POINT |
+ CONTEXT_EXTENDED_REGISTERS |
CONTEXT_DEBUG_REGISTERS;
- GetThreadContext (th->h, &th->context);
+ if (GetThreadContext (th->h, &th->context) == 0) {
+ DWORD e = GetLastError();
+
+ if (e == ERROR_INVALID_PARAMETER) {
+ /* try limited set */
+ th->context.ContextFlags = CONTEXT_FULL |
+ CONTEXT_FLOATING_POINT | CONTEXT_DEBUG_REGISTERS;
+ if (GetThreadContext (th->h, &th->context) == 0) {
+ DWORD e = GetLastError();
+ printf("GetThreadContext failure %d\n", e);
+ return;
+ }
+ }
+ }
debug_registers_changed = 0;
@@ -193,6 +213,12 @@ i386_store_inferior_register (win32_thre
collect_register (r, context_offset);
}
+/*
+ * The INT 3 instruction is used for x86 platform breakpointing.
+ */
+static const unsigned char i386_wince_breakpoint = 0xCC;
+#define i386_wince_breakpoint_len 1
+
struct win32_target_ops the_low_target = {
init_registers_i386,
sizeof (mappings) / sizeof (mappings[0]),
@@ -203,6 +229,6 @@ struct win32_target_ops the_low_target =
i386_fetch_inferior_register,
i386_store_inferior_register,
i386_single_step,
- NULL, /* breakpoint */
- 0, /* breakpoint_len */
+ &i386_wince_breakpoint, /* breakpoint */
+ i386_wince_breakpoint_len, /* breakpoint_len */
};
Index: win32-low.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v
retrieving revision 1.35
diff -u -u -p -r1.35 win32-low.c
--- win32-low.c 1 Apr 2009 22:50:24 -0000 1.35
+++ win32-low.c 1 Jul 2009 19:28:15 -0000
@@ -873,14 +873,19 @@ win32_add_one_solib (const char *name, C
loaded_dll (buf2, load_addr);
}
+/*
+ * Warning : some parts of this function rely on sizeof(WCHAR) == 2
+ */
static char *
get_image_name (HANDLE h, void *address, int unicode)
{
- static char buf[(2 * MAX_PATH) + 1];
+ static char buf[(2 * MAX_PATH) + 1]; /* here */
DWORD size = unicode ? sizeof (WCHAR) : sizeof (char);
char *address_ptr;
+#ifndef _WIN32_WCE
int len = 0;
- char b[2];
+ char b[2]; /* here */
+#endif
DWORD done;
/* Attempt to read the name of the dll that was detected.
@@ -903,9 +908,28 @@ get_image_name (HANDLE h, void *address,
return NULL;
#endif
+#ifdef _WIN32_WCE
+ /* Always unicode */
+ /* Assume you can read it all in one go, or otherwise the done variable will
+ * tell you how far you've read.
+ */
+ WCHAR *wbuf = alloca ((MAX_PATH + 1) * size);
+ ReadProcessMemory (h, address_ptr, wbuf, MAX_PATH * size, &done);
+ if (done < 0 || done > MAX_PATH * size)
+ buf[0] = '\0';
+ else {
+ int n;
+ n = wcstombs (buf, wbuf, done);
+ if (n == (size_t)-1)
+ buf[0] = '\0';
+ /* No need to address the length limit case of the wcstombs call,
+ * buf has been allocated large enough. */
+ }
+ return buf;
+#else
/* Find the length of the string */
while (ReadProcessMemory (h, address_ptr + len++ * size, &b, size, &done)
- && (b[0] != 0 || b[size - 1] != 0) && done == size)
+ && (b[0] != 0 || b[size - 1] != 0) && done == size) /* here */
continue;
if (!unicode)
@@ -920,6 +944,7 @@ get_image_name (HANDLE h, void *address,
}
return buf;
+#endif
}
typedef BOOL (WINAPI *winapi_EnumProcessModules) (HANDLE, HMODULE *,
@@ -1365,7 +1390,20 @@ get_child_debug_event (struct target_wai
interruption, but high enough so gdbserver doesn't become a
bottleneck. */
if (!WaitForDebugEvent (¤t_event, 250))
- return 0;
+ {
+ /*
+ * Sometimes an application will just not start up.
+ * Detect this here, return in such a way that the loop ends.
+ */
+ DWORD e = GetLastError();
+
+ if (e == ERROR_PIPE_NOT_CONNECTED)
+ {
+ ourstatus->kind = TARGET_WAITKIND_EXITED;
+ return 1; /* break the loop in our caller */
+ }
+ return 0;
+ }
}
gotevent:
next prev parent reply other threads:[~2009-07-01 19:31 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-13 14:29 Danny Backx
2009-06-13 18:05 ` Pedro Alves
2009-06-13 18:08 ` Pedro Alves
2009-06-14 8:35 ` Danny Backx
2009-06-14 13:56 ` Pedro Alves
2009-06-14 8:47 ` Danny Backx
2009-06-14 9:48 ` Danny Backx
2009-06-14 14:23 ` Pedro Alves
2009-06-21 9:50 ` Danny Backx
2009-06-30 21:07 ` Danny Backx
2009-06-30 21:56 ` Pedro Alves
2009-07-01 18:41 ` Danny Backx
2009-07-01 18:52 ` Pedro Alves
2009-07-01 19:12 ` Danny Backx
2009-07-01 20:12 ` Pedro Alves
2009-07-04 18:14 ` Pedro Alves
2009-07-08 9:55 ` Danny Backx
2009-07-08 11:34 ` Danny Backx
2009-07-27 20:40 ` Danny Backx
2009-07-01 19:31 ` Danny Backx [this message]
2009-06-14 14:34 ` Pedro Alves
2009-06-14 14:05 ` Pedro Alves
-- strict thread matches above, loose matches on Subject: below --
2009-06-07 9:18 Danny Backx
2009-06-07 17:03 ` Pedro Alves
2009-06-07 18:02 ` Danny Backx
2009-06-07 18:15 ` Pedro Alves
2009-06-07 19:13 ` Danny Backx
2009-06-07 19:28 ` Pedro Alves
2009-06-08 18:13 ` Danny Backx
2009-06-12 22:18 ` Danny Backx
2009-06-13 6:28 ` Johnny Willemsen
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=1246476684.15871.273.camel@pavilion \
--to=danny.backx@scarlet.be \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/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