diff options
author | Pedro Alves <pedro@codesourcery.com> | 2007-05-10 20:48:41 +0000 |
---|---|---|
committer | Pedro Alves <pedro@codesourcery.com> | 2007-05-10 20:48:41 +0000 |
commit | bbb1d51576bf0ee6d20512d662774ed37a78bf67 (patch) | |
tree | f5b5f7e0d6a86ea43e53c247b7c842a4ff58ace1 /gdb/gdbserver | |
parent | 8f17434ae5bad798a83dbe79d539cd86bc492412 (diff) | |
download | gdb-bbb1d51576bf0ee6d20512d662774ed37a78bf67.tar.gz |
* win32-low.c (win32-attach): Fix return value.
* target.h (target_ops): Describe ATTACH return values.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/gdbserver/target.h | 5 | ||||
-rw-r--r-- | gdb/gdbserver/win32-low.c | 29 |
3 files changed, 21 insertions, 18 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index b36dcfb1560..f9499544a66 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,5 +1,10 @@ 2007-05-10 Pedro Alves <pedro_alves@portugalmail.pt> + * win32-low.c (win32-attach): Fix return value. + * target.h (target_ops): Describe ATTACH return values. + +2007-05-10 Pedro Alves <pedro_alves@portugalmail.pt> + * win32-low.c (GETPROCADDRESS): Define. (winapi_DebugActiveProcessStop): Add WINAPI. typedef as pointer. (winapi_DebugSetProcessKillOnExit): Likewise. diff --git a/gdb/gdbserver/target.h b/gdb/gdbserver/target.h index 6f88b49d78b..36cc69a975f 100644 --- a/gdb/gdbserver/target.h +++ b/gdb/gdbserver/target.h @@ -58,7 +58,10 @@ struct target_ops /* Attach to a running process. PID is the process ID to attach to, specified by the user - or a higher layer. */ + or a higher layer. + + Returns -1 if attaching is unsupported, 0 on success, and calls + error() otherwise. */ int (*attach) (unsigned long pid); diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 680cafea182..265c91691fb 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -580,7 +580,6 @@ win32_create_inferior (char *program, char **program_args) static int win32_attach (unsigned long pid) { - int res = 0; winapi_DebugActiveProcessStop DebugActiveProcessStop = NULL; winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL; #ifdef _WIN32_WCE @@ -591,28 +590,24 @@ win32_attach (unsigned long pid) DebugActiveProcessStop = GETPROCADDRESS (dll, DebugActiveProcessStop); DebugSetProcessKillOnExit = GETPROCADDRESS (dll, DebugSetProcessKillOnExit); - res = DebugActiveProcess (pid) ? 1 : 0; - - if (!res) - error ("Attach to process failed."); - - if (DebugSetProcessKillOnExit != NULL) - DebugSetProcessKillOnExit (FALSE); + if (DebugActiveProcess (pid)) + { + if (DebugSetProcessKillOnExit != NULL) + DebugSetProcessKillOnExit (FALSE); - current_process_id = pid; - current_process_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid); + current_process_handle = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pid); - if (current_process_handle == NULL) - { - res = 0; + if (current_process_handle != NULL) + { + current_process_id = pid; + do_initial_child_stuff (pid); + return 0; + } if (DebugActiveProcessStop != NULL) DebugActiveProcessStop (current_process_id); } - if (res) - do_initial_child_stuff (pid); - - return res; + error ("Attach to process failed."); } /* Handle OUTPUT_DEBUG_STRING_EVENT from child process. */ |