* [RFA] win32-nat.c: Add to_pid_to_exec_file function
@ 2004-06-26 12:11 Corinna Vinschen
2004-06-29 14:37 ` Christopher Faylor
0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2004-06-26 12:11 UTC (permalink / raw)
To: gdb-patches
Hi,
the below patch adds a to_pid_to_exec_file function to win32-nat.c
It allows to load the symbol table of a process automatically when
attaching to a running process. So far, without this function, the
symbol table has to be loaded manually (file command).
In this step the new functionality only works for Cygwin processes.
I'm planning to add the same functionality also for native Windows
processes in a next step.
This patch also requires another patch to infcmd.c (attach_command),
which I'm going to submit separately to discuss it separately. It
looks like a more generic problem to me and I'm not exactly sure if
my patch is the best solution.
This patch is the base for running testsuite/gdb.base/attach.exp nearly
FAIL free (I'm locally down to just 1 FAIL), together with a few
adjustments in attach.exp itself. I'll submit the changes to attach.exp
also in a separate posting.
Corinna
* win32-nat.c (child_pid_to_exec_file): New function.
(init_child_ops): Add child_pid_to_exec_file as to_pid_to_exec_file
functionality.
Index: win32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/win32-nat.c,v
retrieving revision 1.92
diff -u -p -r1.92 win32-nat.c
--- win32-nat.c 25 Jun 2004 19:46:08 -0000 1.92
+++ win32-nat.c 26 Jun 2004 08:18:41 -0000
@@ -1656,6 +1656,36 @@ child_detach (char *args, int from_tty)
unpush_target (&child_ops);
}
+char *
+child_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;
+ int cpid;
+ struct external_pinfo *pinfo;
+
+ cygwin_internal (CW_LOCK_PINFO, 1000);
+ for (cpid = 0;
+ (pinfo = (struct external_pinfo *)
+ cygwin_internal (CW_GETPINFO, cpid | CW_NEXTPID));
+ cpid = pinfo->pid)
+ {
+ if (pinfo->dwProcessId == current_event.dwProcessId) /* Got it */
+ {
+ cygwin_conv_to_full_posix_path (pinfo->progname, path);
+ path_ptr = path;
+ break;
+ }
+ }
+ cygwin_internal (CW_UNLOCK_PINFO);
+ return path_ptr;
+}
+
/* Print status information about what we're accessing. */
static void
@@ -2078,6 +2108,7 @@ init_child_ops (void)
child_ops.to_has_registers = 1;
child_ops.to_has_execution = 1;
child_ops.to_magic = OPS_MAGIC;
+ child_ops.to_pid_to_exec_file = child_pid_to_exec_file;
}
void
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] win32-nat.c: Add to_pid_to_exec_file function
2004-06-26 12:11 [RFA] win32-nat.c: Add to_pid_to_exec_file function Corinna Vinschen
@ 2004-06-29 14:37 ` Christopher Faylor
2004-06-29 15:39 ` Corinna Vinschen
0 siblings, 1 reply; 3+ messages in thread
From: Christopher Faylor @ 2004-06-29 14:37 UTC (permalink / raw)
To: gdb-patches
On Sat, Jun 26, 2004 at 02:11:15PM +0200, Corinna Vinschen wrote:
> * win32-nat.c (child_pid_to_exec_file): New function.
> (init_child_ops): Add child_pid_to_exec_file as to_pid_to_exec_file
> functionality.
This is ok. Please apply.
cgf
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFA] win32-nat.c: Add to_pid_to_exec_file function
2004-06-29 14:37 ` Christopher Faylor
@ 2004-06-29 15:39 ` Corinna Vinschen
0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2004-06-29 15:39 UTC (permalink / raw)
To: gdb-patches
On Jun 29 10:37, Christopher Faylor wrote:
> On Sat, Jun 26, 2004 at 02:11:15PM +0200, Corinna Vinschen wrote:
> > * win32-nat.c (child_pid_to_exec_file): New function.
> > (init_child_ops): Add child_pid_to_exec_file as to_pid_to_exec_file
> > functionality.
>
> This is ok. Please apply.
Thanks, applied.
Corinna
--
Corinna Vinschen
Cygwin Co-Project Leader
Red Hat, Inc.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-06-29 15:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-26 12:11 [RFA] win32-nat.c: Add to_pid_to_exec_file function Corinna Vinschen
2004-06-29 14:37 ` Christopher Faylor
2004-06-29 15:39 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox