From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22675 invoked by alias); 4 Dec 2008 01:24:57 -0000 Received: (qmail 22664 invoked by uid 22791); 4 Dec 2008 01:24:55 -0000 X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.45.13) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 04 Dec 2008 01:24:20 +0000 Received: from zps75.corp.google.com (zps75.corp.google.com [172.25.146.75]) by smtp-out.google.com with ESMTP id mB41OIO3003708 for ; Wed, 3 Dec 2008 17:24:18 -0800 Received: from localhost (ruffy.corp.google.com [172.18.118.116]) by zps75.corp.google.com with ESMTP id mB41OHad017336 for ; Wed, 3 Dec 2008 17:24:17 -0800 Received: by localhost (Postfix, from userid 67641) id 1413E1C7A0F; Wed, 3 Dec 2008 17:24:16 -0800 (PST) To: gdb-patches@sourceware.org Subject: [RFA] change gdbserver's pids to int Message-Id: <20081204012417.1413E1C7A0F@localhost> Date: Thu, 04 Dec 2008 01:24:00 -0000 From: dje@google.com (Doug Evans) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-12/txt/msg00053.txt.bz2 gdb uses an int for a pid (see ptid.pid in defs.h), and, for example, gdbserver's target_ops.create_inferior returns an int. For consistency I made pid an int elsewhere in gdbserver, except for "id" in struct inferior_list - it's used for more than just pids although I suspect int could be used here too, left for another day. Plus this cleans things up by removing local decls of signal_pid. Ok to check in? 2008-12-03 Doug Evans * target.h (struct target_ops, attach): Change type of pid arg to int. * server.c (signal_pid): Change to int from unsigned long. (start_inferior): Update. * server.h (signal_pid): Declare. * linux-low.c (linux_attach_lwp): Change type of pid arg to int. (linux_attach): Ditto. (linux_join): Remove decl of signal_pid. (linux_request_interrupt): Ditto. * win32-low.c (win32_join): Ditto. (win32_attach): Change type of pid arg to int. * inferiors.c (add_pid_to_list): Ditto. (pull_pid_from_list): Ditto. * spu-low.c (spu_attach): Ditto. Index: inferiors.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/inferiors.c,v retrieving revision 1.15 diff -u -p -r1.15 inferiors.c --- inferiors.c 3 May 2008 17:16:43 -0000 1.15 +++ inferiors.c 4 Dec 2008 01:14:11 -0000 @@ -310,7 +310,7 @@ clear_inferiors (void) PID listing. */ void -add_pid_to_list (struct inferior_list *list, unsigned long pid) +add_pid_to_list (struct inferior_list *list, int pid) { struct inferior_list_entry *new_entry; @@ -320,7 +320,7 @@ add_pid_to_list (struct inferior_list *l } int -pull_pid_from_list (struct inferior_list *list, unsigned long pid) +pull_pid_from_list (struct inferior_list *list, int pid) { struct inferior_list_entry *new_entry; Index: linux-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.c,v retrieving revision 1.82 diff -u -p -r1.82 linux-low.c --- linux-low.c 2 Dec 2008 07:57:37 -0000 1.82 +++ linux-low.c 4 Dec 2008 01:14:12 -0000 @@ -307,7 +307,7 @@ linux_create_inferior (char *program, ch /* Attach to an inferior process. */ void -linux_attach_lwp (unsigned long pid) +linux_attach_lwp (int pid) { struct process_info *new_process; @@ -316,14 +316,14 @@ linux_attach_lwp (unsigned long pid) if (all_threads.head != NULL) { /* If we fail to attach to an LWP, just warn. */ - fprintf (stderr, "Cannot attach to process %ld: %s (%d)\n", pid, + fprintf (stderr, "Cannot attach to process %d: %s (%d)\n", pid, strerror (errno), errno); fflush (stderr); return; } else /* If we fail to attach to a process, report an error. */ - error ("Cannot attach to process %ld: %s (%d)\n", pid, + error ("Cannot attach to process %d: %s (%d)\n", pid, strerror (errno), errno); } @@ -348,7 +348,7 @@ linux_attach_lwp (unsigned long pid) } int -linux_attach (unsigned long pid) +linux_attach (int pid) { struct process_info *process; @@ -461,7 +461,6 @@ linux_detach (void) static void linux_join (void) { - extern unsigned long signal_pid; int status, ret; do { @@ -1928,8 +1927,6 @@ linux_look_up_symbols (void) static void linux_request_interrupt (void) { - extern unsigned long signal_pid; - if (cont_thread != 0 && cont_thread != -1) { struct process_info *process; Index: linux-low.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/linux-low.h,v retrieving revision 1.23 diff -u -p -r1.23 linux-low.h --- linux-low.h 28 Feb 2008 05:54:09 -0000 1.23 +++ linux-low.h 4 Dec 2008 01:14:12 -0000 @@ -140,7 +140,7 @@ struct process_info extern struct inferior_list all_processes; -void linux_attach_lwp (unsigned long pid); +void linux_attach_lwp (int pid); int thread_db_init (int use_events); int thread_db_get_tls_address (struct thread_info *thread, CORE_ADDR offset, Index: server.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.c,v retrieving revision 1.81 diff -u -p -r1.81 server.c --- server.c 2 Dec 2008 07:57:37 -0000 1.81 +++ server.c 4 Dec 2008 01:14:12 -0000 @@ -60,8 +60,7 @@ const char *gdbserver_xmltarget; send signals to the process when GDB sends us an asynchronous interrupt (user hitting Control-C in the client), and to wait for the child to exit when no longer debugging it. */ - -unsigned long signal_pid; +int signal_pid; #ifdef SIGTTOU /* A file descriptor for the controlling terminal. */ @@ -125,7 +124,7 @@ start_inferior (char **argv, char *statu /* FIXME: we don't actually know at this point that the create actually succeeded. We won't know that until we wait. */ - fprintf (stderr, "Process %s created; pid = %ld\n", argv[0], + fprintf (stderr, "Process %s created; pid = %d\n", argv[0], signal_pid); fflush (stderr); Index: server.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/server.h,v retrieving revision 1.47 diff -u -p -r1.47 server.h --- server.h 2 Dec 2008 07:57:37 -0000 1.47 +++ server.h 4 Dec 2008 01:14:12 -0000 @@ -141,8 +141,8 @@ void *inferior_target_data (struct threa void set_inferior_target_data (struct thread_info *, void *); void *inferior_regcache_data (struct thread_info *); void set_inferior_regcache_data (struct thread_info *, void *); -void add_pid_to_list (struct inferior_list *list, unsigned long pid); -int pull_pid_from_list (struct inferior_list *list, unsigned long pid); +void add_pid_to_list (struct inferior_list *list, int pid); +int pull_pid_from_list (struct inferior_list *list, int pid); void loaded_dll (const char *name, CORE_ADDR base_addr); void unloaded_dll (const char *name, CORE_ADDR base_addr); @@ -157,9 +157,8 @@ extern unsigned long old_thread_from_wai extern int server_waiting; extern int debug_threads; extern int pass_signals[]; - extern jmp_buf toplevel; - +extern int signal_pid; extern int disable_packet_vCont; extern int disable_packet_Tthread; extern int disable_packet_qC; Index: spu-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/spu-low.c,v retrieving revision 1.17 diff -u -p -r1.17 spu-low.c --- spu-low.c 28 Feb 2008 05:54:09 -0000 1.17 +++ spu-low.c 4 Dec 2008 01:14:12 -0000 @@ -295,7 +295,7 @@ spu_create_inferior (char *program, char /* Attach to an inferior process. */ int -spu_attach (unsigned long pid) +spu_attach (int pid) { if (ptrace (PTRACE_ATTACH, pid, 0, 0) != 0) { Index: target.h =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/target.h,v retrieving revision 1.29 diff -u -p -r1.29 target.h --- target.h 2 Dec 2008 07:57:37 -0000 1.29 +++ target.h 4 Dec 2008 01:14:12 -0000 @@ -62,7 +62,7 @@ struct target_ops Returns -1 if attaching is unsupported, 0 on success, and calls error() otherwise. */ - int (*attach) (unsigned long pid); + int (*attach) (int pid); /* Kill all inferiors. */ Index: win32-low.c =================================================================== RCS file: /cvs/src/src/gdb/gdbserver/win32-low.c,v retrieving revision 1.27 diff -u -p -r1.27 win32-low.c --- win32-low.c 28 Feb 2008 05:54:09 -0000 1.27 +++ win32-low.c 4 Dec 2008 01:14:12 -0000 @@ -588,7 +588,7 @@ win32_create_inferior (char *program, ch PID is the process ID to attach to, specified by the user or a higher layer. */ static int -win32_attach (unsigned long pid) +win32_attach (int pid) { HANDLE h; winapi_DebugSetProcessKillOnExit DebugSetProcessKillOnExit = NULL; @@ -743,8 +743,6 @@ win32_detach (void) static void win32_join (void) { - extern unsigned long signal_pid; - HANDLE h = OpenProcess (PROCESS_ALL_ACCESS, FALSE, signal_pid); if (h != NULL) {