From: Corinna Vinschen Date: Tue, 29 Jun 2004 15:37:31 +0000 (+0000) Subject: * win32-nat.c (child_pid_to_exec_file): New function. X-Git-Tag: csl-arm-2004-q3~1025 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=47216e511866495b7ece0227ef53f99cf23eda00;p=external%2Fbinutils.git * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index f459101..ca53c25 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,9 @@ +2004-06-29 Corinna Vinschen + + * 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. + 2004-06-28 Andrew Cagney * defs.h (xstrvprintf): Declare. diff --git a/gdb/win32-nat.c b/gdb/win32-nat.c index b8e5380..e1e865b 100644 --- a/gdb/win32-nat.c +++ b/gdb/win32-nat.c @@ -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 diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index b8e5380..e1e865b 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -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