From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6971 invoked by alias); 16 Mar 2012 15:02:05 -0000 Received: (qmail 6950 invoked by uid 22791); 16 Mar 2012 15:02:03 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,FROM_12LTRDOM X-Spam-Check-By: sourceware.org Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 16 Mar 2012 15:01:47 +0000 Received: from svr-orw-exc-10.mgc.mentorg.com ([147.34.98.58]) by relay1.mentorg.com with esmtp id 1S8Yep-0000MM-MS from Yao_Qi@mentor.com for gdb-patches@sourceware.org; Fri, 16 Mar 2012 08:01:31 -0700 Received: from SVR-ORW-FEM-02.mgc.mentorg.com ([147.34.96.206]) by SVR-ORW-EXC-10.mgc.mentorg.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 16 Mar 2012 08:01:29 -0700 Received: from localhost.localdomain (147.34.91.1) by svr-orw-fem-02.mgc.mentorg.com (147.34.96.168) with Microsoft SMTP Server id 14.1.289.1; Fri, 16 Mar 2012 08:01:29 -0700 From: Yao Qi To: Subject: [PATCH 5/5] move server.h to gdbthread.h. Date: Fri, 16 Mar 2012 15:02:00 -0000 Message-ID: <1331909994-9473-6-git-send-email-yao@codesourcery.com> In-Reply-To: <1331909994-9473-1-git-send-email-yao@codesourcery.com> References: <1331909994-9473-1-git-send-email-yao@codesourcery.com> MIME-Version: 1.0 Content-Type: text/plain 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: 2012-03/txt/msg00617.txt.bz2 This patch is to move thread-related code out of server.h, and include gdbthread.h in those c files. The motivation of this change is that we've put too much stuff in a single server.h, so it is reasonable to move them out to separate headers. gdb/gdbserver: 2012-03-16 Yao Qi * server.h: Move some code to ... * gdbthread.h: ... here. New. * Makefile.in (inferiors.o, regcache.o): Depends on gdbthread.h (remote-utils.o, server.o, target.o tracepoint.o): Likewise. (nto-low.o, win32-low.o): Likewise. * inferiors.c, linux-low.h, nto-low.c: Include gdbthread.h. * regcache.c, remote-utils.c, server.c: Likewise. * target.c, tracepoint.c, win32-low.c: Likewise. --- gdb/gdbserver/Makefile.in | 19 ++++++++------- gdb/gdbserver/gdbthread.h | 53 ++++++++++++++++++++++++++++++++++++++++++ gdb/gdbserver/inferiors.c | 1 + gdb/gdbserver/linux-low.h | 1 + gdb/gdbserver/nto-low.c | 1 + gdb/gdbserver/regcache.c | 1 + gdb/gdbserver/remote-utils.c | 1 + gdb/gdbserver/server.c | 1 + gdb/gdbserver/server.h | 45 +---------------------------------- gdb/gdbserver/target.c | 1 + gdb/gdbserver/tracepoint.c | 1 + gdb/gdbserver/win32-low.c | 1 + 12 files changed, 73 insertions(+), 53 deletions(-) create mode 100644 gdb/gdbserver/gdbthread.h diff --git a/gdb/gdbserver/Makefile.in b/gdb/gdbserver/Makefile.in index fbcdbcb..98d460c 100644 --- a/gdb/gdbserver/Makefile.in +++ b/gdb/gdbserver/Makefile.in @@ -352,7 +352,8 @@ server_h = $(srcdir)/server.h $(regcache_h) config.h $(srcdir)/target.h \ $(ptid_h) \ $(signals_h) $(inferior_h) -linux_low_h = $(srcdir)/linux-low.h +gdbthread_h = $(srcdir)/gdbthread.h $(target_h) $(inferior_h) +linux_low_h = $(srcdir)/linux-low.h $(gdbthread_h) linux_ptrace_h = $(srcdir)/../common/linux-ptrace.h @@ -398,16 +399,16 @@ ax.o: ax.c $(server_h) $(ax_h) $(srcdir)/../common/ax.def event-loop.o: event-loop.c $(server_h) hostio.o: hostio.c $(server_h) hostio-errno.o: hostio-errno.c $(server_h) -inferiors.o: inferiors.c $(server_h) +inferiors.o: inferiors.c $(server_h) $(gdbthread_h) mem-break.o: mem-break.c $(server_h) $(ax_h) proc-service.o: proc-service.c $(server_h) $(gdb_proc_service_h) -regcache.o: regcache.c $(server_h) $(regdef_h) -remote-utils.o: remote-utils.c terminal.h $(server_h) -server.o: server.c $(server_h) $(agent_h) -target.o: target.c $(server_h) +regcache.o: regcache.c $(server_h) $(regdef_h) $(gdbthread_h) +remote-utils.o: remote-utils.c terminal.h $(server_h) $(gdbthread_h) +server.o: server.c $(server_h) $(agent_h) $(gdbthread_h) +target.o: target.c $(server_h) thread-db.o: thread-db.c $(server_h) $(linux_low_h) $(gdb_proc_service_h) \ $(gdb_thread_db_h) -tracepoint.o: tracepoint.c $(server_h) $(ax_h) $(agent_h) +tracepoint.o: tracepoint.c $(server_h) $(ax_h) $(agent_h) $(gdbthread_h) utils.o: utils.c $(server_h) gdbreplay.o: gdbreplay.c config.h dll.o: dll.c $(server_h) @@ -485,12 +486,12 @@ linux-xtensa-low.o: linux-xtensa-low.c xtensa-xtregs.c $(linux_low_h) $(server_h lynx-low.o: lynx-low.c $(server_h) $(target_h) $(lynx_low_h) lynx-ppc-low.o: lynx-ppc-low.c $(server_h) $(lynx_low_h) -nto-low.o: nto-low.c $(server_h) $(nto_low_h) +nto-low.o: nto-low.c $(server_h) $(nto_low_h) $(gdbthread_h) nto-x86-low.o: nto-x86-low.c $(server_h) $(nto_low_h) $(regdef_h) $(regcache_h) win32_low_h = $(srcdir)/win32-low.h -win32-low.o: win32-low.c $(win32_low_h) $(server_h) $(regdef_h) $(regcache_h) +win32-low.o: win32-low.c $(win32_low_h) $(server_h) $(regdef_h) $(regcache_h) $(gdbthread_h) win32-arm-low.o: win32-arm-low.c $(win32_low_h) $(server_h) win32-i386-low.o: win32-i386-low.c $(win32_low_h) $(server_h) $(i386_low_h) diff --git a/gdb/gdbserver/gdbthread.h b/gdb/gdbserver/gdbthread.h new file mode 100644 index 0000000..d42b6fd --- /dev/null +++ b/gdb/gdbserver/gdbthread.h @@ -0,0 +1,53 @@ +#ifndef GDB_THREAD_H +#define GDB_THREAD_H + +#include "target.h" +#include "inferior.h" + +struct thread_info +{ + struct inferior_list_entry entry; + void *target_data; + void *regcache_data; + + /* The last resume GDB requested on this thread. */ + enum resume_kind last_resume_kind; + + /* The last wait status reported for this thread. */ + struct target_waitstatus last_status; + + /* Given `while-stepping', a thread may be collecting data for more + than one tracepoint simultaneously. E.g.: + + ff0001 INSN1 <-- TP1, while-stepping 10 collect $regs + ff0002 INSN2 + ff0003 INSN3 <-- TP2, collect $regs + ff0004 INSN4 <-- TP3, while-stepping 10 collect $regs + ff0005 INSN5 + + Notice that when instruction INSN5 is reached, the while-stepping + actions of both TP1 and TP3 are still being collected, and that TP2 + had been collected meanwhile. The whole range of ff0001-ff0005 + should be single-stepped, due to at least TP1's while-stepping + action covering the whole range. + + On the other hand, the same tracepoint with a while-stepping action + may be hit by more than one thread simultaneously, hence we can't + keep the current step count in the tracepoint itself. + + This is the head of the list of the states of `while-stepping' + tracepoint actions this thread is now collecting; NULL if empty. + Each item in the list holds the current step of the while-stepping + action. */ + struct wstep_state *while_stepping; +}; + +extern struct inferior_list all_threads; + +void remove_thread (struct thread_info *thread); +void add_thread (ptid_t ptid, void *target_data); + +struct thread_info *find_thread_ptid (ptid_t ptid); +struct thread_info *gdb_id_to_thread (unsigned int); + +#endif /* GDB_THREAD_H */ diff --git a/gdb/gdbserver/inferiors.c b/gdb/gdbserver/inferiors.c index 1deeceb..94a16d8 100644 --- a/gdb/gdbserver/inferiors.c +++ b/gdb/gdbserver/inferiors.c @@ -21,6 +21,7 @@ #include #include "server.h" +#include "gdbthread.h" struct inferior_list all_processes; struct inferior_list all_threads; diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h index b4af546..e934867 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h @@ -21,6 +21,7 @@ #include #endif +#include "gdbthread.h" #include "gdb_proc_service.h" #ifdef HAVE_LINUX_REGSETS diff --git a/gdb/gdbserver/nto-low.c b/gdb/gdbserver/nto-low.c index 9ac9731..2b60b3b 100644 --- a/gdb/gdbserver/nto-low.c +++ b/gdb/gdbserver/nto-low.c @@ -19,6 +19,7 @@ #include "server.h" +#include "gdbthread.h" #include "nto-low.h" #include diff --git a/gdb/gdbserver/regcache.c b/gdb/gdbserver/regcache.c index 5eda9df..5e4c149 100644 --- a/gdb/gdbserver/regcache.c +++ b/gdb/gdbserver/regcache.c @@ -19,6 +19,7 @@ #include "server.h" #include "regdef.h" +#include "gdbthread.h" #include #include diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c index 025643a..5092842 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c @@ -19,6 +19,7 @@ #include "server.h" #include "terminal.h" #include "target.h" +#include "gdbthread.h" #include #include #if HAVE_SYS_IOCTL_H diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index af6bfcc..3a88e0d 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -18,6 +18,7 @@ along with this program. If not, see . */ #include "server.h" +#include "gdbthread.h" #include "agent.h" #if HAVE_UNISTD_H diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h index e95eaeb..b8404e5 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h @@ -143,44 +143,6 @@ struct regcache; #include "target.h" #include "mem-break.h" -struct thread_info -{ - struct inferior_list_entry entry; - void *target_data; - void *regcache_data; - - /* The last resume GDB requested on this thread. */ - enum resume_kind last_resume_kind; - - /* The last wait status reported for this thread. */ - struct target_waitstatus last_status; - - /* Given `while-stepping', a thread may be collecting data for more - than one tracepoint simultaneously. E.g.: - - ff0001 INSN1 <-- TP1, while-stepping 10 collect $regs - ff0002 INSN2 - ff0003 INSN3 <-- TP2, collect $regs - ff0004 INSN4 <-- TP3, while-stepping 10 collect $regs - ff0005 INSN5 - - Notice that when instruction INSN5 is reached, the while-stepping - actions of both TP1 and TP3 are still being collected, and that TP2 - had been collected meanwhile. The whole range of ff0001-ff0005 - should be single-stepped, due to at least TP1's while-stepping - action covering the whole range. - - On the other hand, the same tracepoint with a while-stepping action - may be hit by more than one thread simultaneously, hence we can't - keep the current step count in the tracepoint itself. - - This is the head of the list of the states of `while-stepping' - tracepoint actions this thread is now collecting; NULL if empty. - Each item in the list holds the current step of the while-stepping - action. */ - struct wstep_state *while_stepping; -}; - struct dll_info { struct inferior_list_entry entry; @@ -202,7 +164,6 @@ void initialize_low (); /* From inferiors.c. */ extern struct inferior_list all_processes; -extern struct inferior_list all_threads; extern struct inferior_list all_dlls; extern int dlls_changed; extern void clear_dlls (void); @@ -215,8 +176,6 @@ void for_each_inferior (struct inferior_list *list, extern struct thread_info *current_inferior; void remove_inferior (struct inferior_list *list, struct inferior_list_entry *entry); -void remove_thread (struct thread_info *thread); -void add_thread (ptid_t ptid, void *target_data); struct inferior *add_process (int pid, int attached); void remove_process (struct inferior *process); @@ -224,12 +183,10 @@ struct inferior *find_process_pid (int pid); int have_started_inferiors_p (void); int have_attached_inferiors_p (void); -struct thread_info *find_thread_ptid (ptid_t ptid); - ptid_t thread_id_to_gdb_id (ptid_t); ptid_t thread_to_gdb_id (struct thread_info *); ptid_t gdb_id_to_thread_id (ptid_t); -struct thread_info *gdb_id_to_thread (unsigned int); + void clear_inferiors (void); struct inferior_list_entry *find_inferior (struct inferior_list *, diff --git a/gdb/gdbserver/target.c b/gdb/gdbserver/target.c index 998d6c1..fb128fd 100644 --- a/gdb/gdbserver/target.c +++ b/gdb/gdbserver/target.c @@ -20,6 +20,7 @@ along with this program. If not, see . */ #include "server.h" +#include "gdbthread.h" struct target_ops *the_target; diff --git a/gdb/gdbserver/tracepoint.c b/gdb/gdbserver/tracepoint.c index 21e58ff..5ab0853 100644 --- a/gdb/gdbserver/tracepoint.c +++ b/gdb/gdbserver/tracepoint.c @@ -17,6 +17,7 @@ along with this program. If not, see . */ #include "server.h" +#include "gdbthread.h" #include "agent.h" #include diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index b9b16f3..cfc283d 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -24,6 +24,7 @@ #include "gdb/fileio.h" #include "mem-break.h" #include "win32-low.h" +#include "gdbthread.h" #include #include -- 1.7.0.4