From ca6724c16a360b6297d7827cfd0173441ccd95c2 Mon Sep 17 00:00:00 2001 From: Kevin Buettner Date: Tue, 15 May 2001 00:03:38 +0000 Subject: Redefine ptid_t to be a struct rather than an int. --- gdb/ChangeLog | 67 ++++++++++++++++++++++++++++++++++++++++ gdb/arm-linux-nat.c | 10 ++---- gdb/config/i386/tm-i386sol2.h | 8 ----- gdb/config/i386/tm-i386v42mp.h | 32 +++++++++++++++++-- gdb/config/nm-linux.h | 8 ----- gdb/config/sparc/tm-sun4sol2.h | 6 ---- gdb/corelow.c | 15 --------- gdb/defs.h | 70 ++++++++++++++++++++++-------------------- gdb/i386-linux-nat.c | 11 ------- gdb/inferior.h | 27 ++++++++++++++++ gdb/infptrace.c | 16 ---------- gdb/infrun.c | 68 +++++++++++++++++++++++++++++++++++++++- gdb/lin-lwp.c | 16 +++------- gdb/lin-thread.c | 32 ++++++++++--------- gdb/proc-service.c | 4 --- gdb/procfs.c | 12 -------- gdb/sol-thread.c | 17 +++++----- gdb/thread-db.c | 21 +++++-------- 18 files changed, 267 insertions(+), 173 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e1088e1..8e3a4fc 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,70 @@ +2001-05-14 Kevin Buettner + + * inferior.h (null_ptid, minus_one_ptid): New variable declarations. + (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) + (ptid_get_tid, ptid_equal): New function declarations. + * infrun.c (null_ptid, minus_one_ptid): New variables. + (ptid_build, pid_to_ptid, ptid_get_pid, ptid_get_lwp) + (ptid_get_tid, ptid_equal): New functions. + (_initialize_infrun): Initialize null_ptid, minus_one_ptid, + inferior_ptid, and target_last_wait_ptid. + + * defs.h (ptid_t): Redefine to be a struct rather than an int. + (pid_to_ptid, null_ptid, ptid_equal): Delete these macros. + (PIDGET, TIDGET, MERGEPID): Redefine these macros using the + new ptid accessors and constructor. + + * config/i386/tm-i386v42mp.h (PIDGET, TIDGET, LIDGET, MERGEPID, + MKLID, MKTID, ISTID): Provide new definitions for these macros. + The old macros are retained, but disabled via #if 0 in order + to aid in future restructuring. See FIXME. + + * arm-linux-nat.c (PIDGET, TIDGET): Delete macro definitions. + * i386-linux-nat.c (PIDGET, TIDGET): Likewise. + * infptrace.c (PIDGET, TIDGET): Likewise. + * lin-lwp.c (PIDGET0, PIDGET, TIDGET, MERGEPID): Likewise. + * lin-thread.c (PIDGET0, PIDGET, TIDGET, MERGEPID): Likewise. + * proc-service.c (MERGEPID): Likewise. + * procfs.c (PIDGET, TIDGET, MERGEPID): Likewise. + * thread-db.c (PIDGET0, PIDGET, TIDGET, MERGEPID): Likewise. + * config/nm-linux.h (PIDGET0, PIDGET, TIDGET, MERGEPID): Likewise. + * config/i386/tm-i386sol2.h (PIDGET0, PIDGET, TIDGET, MERGEPID): + Likewise. + * config/sparc/tm-sun4sol2.h (PIDGET0, PIDGET, TIDGET, MERGEPID): + Likewise. + + * lin-lwp.c (THREAD_FLAG): Delete macro definition. + (GET_LWP): Redefine in terms of ptid_get_lwp(). + (GET_PID): Redefine in terms of ptid_get_pid(). + (is_lwp): Redefine without the need for THREAD_FLAG. + (BUILD_LWP): Redefine in terms of ptid_build(). + * lin-thread.c (THREAD_FLAG): Delete macro definition. + (GET_LWP): Redefine in terms of ptid_get_lwp(). + (GET_PID): Redefine in terms of ptid_get_pid(). + (GET_THREAD): Redefine in terms of ptid_get_tid(). + (BUILD_THREAD, BUILD_LWP): Redefine in terms of ptid_build(). + (is_lwp, is_thread): Redefine. + (linux_child_wait, check_all_signal_numbers) + (linuxthreads_discard_global_state, attach_thread): Declare these + functions to squash warnings about missing declarations. + * sol-thread.c (THREAD_FLAG): Delete macro definition. + (GET_PID): Redefine in terms of ptid_get_pid(). + (GET_LWP): Redefine in terms of ptid_get_lwp(). + (GET_THREAD): Redefine in terms of ptid_get_tid(). + (BUILD_THREAD, BUILD_LWP): Redefine in terms of ptid_build(). + (is_lwp, is_thread): Redefine. + * thread-db.c (THREAD_FLAG): Delete macro definition. + (GET_PID): Redefine in terms of ptid_get_pid(). + (GET_LWP): Redefine in terms of ptid_get_lwp(). + (GET_THREAD): Redefine in terms of ptid_get_tid(). + (BUILD_THREAD, BUILD_LWP): Redefine in terms of ptid_build(). + (is_lwp, is_thread): Redefine. + + * corelow.c (add_to_thread_list, get_core_register_section): + Eliminate hacks needed to prevent regressions when inferior_ptid + wasn't wide enough to hold the core file thread id in the pid + component of inferior_ptid. + 2001-05-14 Michael Snyder * remote.c (hex2bin): Make first argument const. diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c index 96c7834..50368b7 100644 --- a/gdb/arm-linux-nat.c +++ b/gdb/arm-linux-nat.c @@ -79,14 +79,8 @@ static unsigned int os_version, os_major, os_minor, os_release; /* On Linux, threads are implemented as pseudo-processes, in which case we may be tracing more than one process at a time. In that case, inferior_ptid will contain the main process ID and the - individual thread (process) ID mashed together. These macros are - used to separate them out. These definitions should be overridden - if thread support is included. */ - -#if !defined (PIDGET) /* Default definition for PIDGET/TIDGET. */ -#define PIDGET(PID) PID -#define TIDGET(PID) 0 -#endif + individual thread (process) ID. get_thread_id () is used to + get the thread id if it's available, and the process id otherwise. */ int get_thread_id (ptid_t ptid) diff --git a/gdb/config/i386/tm-i386sol2.h b/gdb/config/i386/tm-i386sol2.h index f3ebcd9..bc2a5f8 100644 --- a/gdb/config/i386/tm-i386sol2.h +++ b/gdb/config/i386/tm-i386sol2.h @@ -51,12 +51,4 @@ extern char *sunpro_static_transform_name (char *); #define FAULTED_USE_SIGINFO -/* Macros to extract process id and thread id from a composite pid/tid. - Allocate lower 16 bits for process id, next 15 bits for thread id, and - one bit for a flag to indicate a user thread vs. a kernel thread. */ -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) - #endif /* ifndef TM_I386SOL2_H */ diff --git a/gdb/config/i386/tm-i386v42mp.h b/gdb/config/i386/tm-i386v42mp.h index e70bc4d..5671e42 100644 --- a/gdb/config/i386/tm-i386v42mp.h +++ b/gdb/config/i386/tm-i386v42mp.h @@ -30,6 +30,7 @@ #define UNIXWARE +#if 0 /* The following macros extract process and lwp/thread ids from a composite id. @@ -43,8 +44,7 @@ #define PIDBITS 16 /* Return the process id stored in composite PID. */ -#define PIDGET0(PID) (((PID) & ((1 << PIDBITS) - 1))) -#define PIDGET(PID) ((PIDGET0 (PID) == ((1 << PIDBITS) -1)) ? -1 : PIDGET0 (PID)) +#define PIDGET(PID) (((PID) & ((1 << PIDBITS) - 1))) /* Return the thread or lwp id stored in composite PID. */ #define TIDGET(PID) (((PID) & 0x3fffffff) >> PIDBITS) @@ -61,5 +61,33 @@ /* Return whether PID contains a user-space thread id. */ #define ISTID(PID) ((PID) & 0x40000000) +#endif + +/* New definitions of the ptid stuff. Due to the way the + code is structured in uw-thread.c, I'm overloading the thread id + and lwp id onto the lwp field. The tid field is used to indicate + whether the lwp is a tid or not. + + FIXME: Check that core file support is not broken. (See original + #if 0'd comments above.) + FIXME: Restructure uw-thread.c so that the struct ptid fields + can be used as intended. */ + +/* Return the process id stored in composite PID. */ +#define PIDGET(PID) (ptid_get_pid (PID)) + +/* Return the thread or lwp id stored in composite PID. */ +#define TIDGET(PID) (ptid_get_lwp (PID)) +#define LIDGET(PID) TIDGET(PID) + +#define MERGEPID(PID, LID) (ptid_build ((PID), (LID), 0)) +#define MKLID(PID, LID) (ptid_build ((PID), (LID), 0)) + +/* Construct a composite id from thread TID and the process portion of + composite PID. */ +#define MKTID(PID, TID) (ptid_build ((PID), (TID), 1)) + +/* Return whether PID contains a user-space thread id. */ +#define ISTID(PID) (ptid_get_tid (PID)) #endif /* ifndef TM_I386V42MP_H */ diff --git a/gdb/config/nm-linux.h b/gdb/config/nm-linux.h index 19d6857..f1e785c 100644 --- a/gdb/config/nm-linux.h +++ b/gdb/config/nm-linux.h @@ -49,14 +49,6 @@ extern int linuxthreads_prepare_to_proceed (int step); /* Defined to make stepping-over-breakpoints be thread-atomic. */ #define USE_THREAD_STEP_NEEDED 1 -/* Macros to extract process id and thread id from a composite pid/tid. - Allocate lower 19 bits for process id, next 12 bits for thread id, and - one bit for a flag to indicate a user thread vs. a kernel thread. */ -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) - /* Use elf_gregset_t and elf_fpregset_t, rather than gregset_t and fpregset_t. */ diff --git a/gdb/config/sparc/tm-sun4sol2.h b/gdb/config/sparc/tm-sun4sol2.h index 09f36bb..f9b739c 100644 --- a/gdb/config/sparc/tm-sun4sol2.h +++ b/gdb/config/sparc/tm-sun4sol2.h @@ -80,9 +80,3 @@ extern char *sunpro_static_transform_name (char *); /* Enable handling of shared libraries for a.out executables. */ #define HANDLE_SVR4_EXEC_EMULATORS - -/* Macros to extract process id and thread id from a composite pid/tid */ -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) diff --git a/gdb/corelow.c b/gdb/corelow.c index e0a4b6a..5d8d3ce 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -248,14 +248,7 @@ add_to_thread_list (bfd *abfd, asection *asect, PTR reg_sect_arg) if (reg_sect != NULL && asect->filepos == reg_sect->filepos) /* Did we find .reg? */ -#ifdef pid_to_ptid - /* Needed to prevent regressions in ptid conversion phase 1. This - bit of code will be deleted in favor of the #else branch in - phase 3. */ - inferior_ptid = thread_id; /* Yes, make it current */ -#else inferior_ptid = pid_to_ptid (thread_id); /* Yes, make it current */ -#endif } /* This routine opens and sets up the core file bfd. */ @@ -413,16 +406,8 @@ get_core_register_section (char *name, bfd_size_type size; char *contents; -#ifdef pid_to_ptid - /* Needed to prevent regressions in ptid conversion phase 1. This - bit of code will be deleted in favor of the #else branch in - phase 3. */ - if (inferior_ptid) - sprintf (section_name, "%s/%d", name, inferior_ptid); -#else if (PIDGET (inferior_ptid)) sprintf (section_name, "%s/%d", name, PIDGET (inferior_ptid)); -#endif else strcpy (section_name, name); diff --git a/gdb/defs.h b/gdb/defs.h index 166dde8..435e47b 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -844,36 +844,37 @@ enum val_prettyprint Val_pretty_default }; -/* A collection of the various "ids" necessary for identifying - the inferior. This consists of the process id (pid, thread - id (tid), and other fields necessary for uniquely identifying - the inferior process/thread being debugged. - - The present typedef is obviously quite naive with respect to - the magnitudes that real life pids and tids can take on and - will be replaced with something more robust shortly. */ - -typedef int ptid_t; - -/* Convert a pid to a ptid_t. This macro is temporary and will - be replaced shortly. */ - -#define pid_to_ptid(PID) ((ptid_t) MERGEPID ((PID),0)) - -/* Define a value for the null (or zero) pid. This macro is temporary - and will go away shortly. */ - -#define null_ptid (pid_to_ptid (0)) - -/* Define a value for the -1 pid. This macro is temporary and will go - away shortly. */ +/* The ptid struct is a collection of the various "ids" necessary + for identifying the inferior. This consists of the process id + (pid), thread id (tid), and other fields necessary for uniquely + identifying the inferior process/thread being debugged. When + manipulating ptids, the constructors, accessors, and predicate + declared in inferior.h should be used. These are as follows: + + ptid_build - Make a new ptid from a pid, lwp, and tid. + pid_to_ptid - Make a new ptid from just a pid. + ptid_get_pid - Fetch the pid component of a ptid. + ptid_get_lwp - Fetch the lwp component of a ptid. + ptid_get_tid - Fetch the tid component of a ptid. + ptid_equal - Test to see if two ptids are equal. + + Please do NOT access the struct ptid members directly (except, of + course, in the implementation of the above ptid manipulation + functions). */ + +struct ptid + { + /* Process id */ + int pid; -#define minus_one_ptid (pid_to_ptid (-1)) + /* Lightweight process id */ + long lwp; -/* Define a ptid comparison operator. This macro is temporary and will - be replaced with a real function shortly. */ + /* Thread id */ + long tid; + }; -#define ptid_equal(PTID1,PTID2) ((PTID1) == (PTID2)) +typedef struct ptid ptid_t; @@ -1391,15 +1392,16 @@ extern int use_windows; #define ROOTED_P(X) (SLASH_P((X)[0])) #endif -/* On some systems, PIDGET is defined to extract the inferior pid from - an internal pid that has the thread id and pid in seperate bit - fields. If not defined, then just use the entire internal pid as - the actual pid. */ +/* Provide default definitions of PIDGET, TIDGET, and MERGEPID. + The name ``TIDGET'' is a historical accident. Many uses of TIDGET + in the code actually refer to a lightweight process id, i.e, + something that can be considered a process id in its own right for + certain purposes. */ #ifndef PIDGET -#define PIDGET(PID) (PID) -#define TIDGET(PID) 0 -#define MERGEPID(PID, TID) (PID) +#define PIDGET(PTID) (ptid_get_pid (PTID)) +#define TIDGET(PTID) (ptid_get_lwp (PTID)) +#define MERGEPID(PID, TID) ptid_build (PID, TID, 0) #endif /* Define well known filenos if the system does not define them. */ diff --git a/gdb/i386-linux-nat.c b/gdb/i386-linux-nat.c index eb222fd..94d9ab3 100644 --- a/gdb/i386-linux-nat.c +++ b/gdb/i386-linux-nat.c @@ -61,17 +61,6 @@ /* Prototypes for local functions. */ static void dummy_sse_values (void); -/* On Linux, threads are implemented as pseudo-processes, in which - case we may be tracing more than one process at a time. In that - case, inferior_ptid will contain the main process ID and the - individual thread (process) ID mashed together. These macros are - used to separate them out. These definitions should be overridden - if thread support is included. */ - -#if !defined (PIDGET) /* Default definition for PIDGET/TIDGET. */ -#define PIDGET(PID) PID -#define TIDGET(PID) 0 -#endif /* The register sets used in Linux ELF core-dumps are identical to the diff --git a/gdb/inferior.h b/gdb/inferior.h index 9174197..502d3ef 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -51,6 +51,33 @@ extern void write_inferior_status_register (struct inferior_status *inf_status, int regno, LONGEST val); +/* The -1 ptid, often used to indicate either an error condition + or a "don't care" condition, i.e, "run all threads." */ +extern ptid_t minus_one_ptid; + +/* The null or zero ptid, often used to indicate no process. */ +extern ptid_t null_ptid; + +/* Attempt to find and return an existing ptid with the given PID, LWP, + and TID components. If none exists, create a new one and return + that. */ +ptid_t ptid_build (int pid, long lwp, long tid); + +/* Find/Create a ptid from just a pid. */ +ptid_t pid_to_ptid (int pid); + +/* Fetch the pid (process id) component from a ptid. */ +int ptid_get_pid (ptid_t ptid); + +/* Fetch the lwp (lightweight process) component from a ptid. */ +long ptid_get_lwp (ptid_t ptid); + +/* Fetch the tid (thread id) component from a ptid. */ +long ptid_get_tid (ptid_t ptid); + +/* Compare two ptids to see if they are equal */ +extern int ptid_equal (ptid_t p1, ptid_t p2); + /* Save value of inferior_ptid so that it may be restored by a later call to do_cleanups(). Returns the struct cleanup pointer needed for later doing the cleanup. */ diff --git a/gdb/infptrace.c b/gdb/infptrace.c index d9eee36..3be3614 100644 --- a/gdb/infptrace.c +++ b/gdb/infptrace.c @@ -110,22 +110,6 @@ static void fetch_register (int); static void store_register (int); #endif -/* - * Some systems (Linux) may have threads implemented as pseudo-processes, - * in which case we may be tracing more than one process at a time. - * In that case, inferior_pid will contain the main process ID and the - * individual thread (process) id mashed together. These macros are - * used to separate them out. The definitions may be overridden in tm.h - * - * NOTE: default definitions here are for systems with no threads. - * Useful definitions MUST be provided in tm.h - */ - -#if !defined (PIDGET) /* Default definition for PIDGET/TIDGET. */ -#define PIDGET(PID) PID -#define TIDGET(PID) 0 -#endif - void _initialize_kernel_u_addr (void); void _initialize_infptrace (void); diff --git a/gdb/infrun.c b/gdb/infrun.c index 21d07f2..824b610 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -4192,7 +4192,67 @@ discard_inferior_status (struct inferior_status *inf_status) free_inferior_status (inf_status); } -/* Helper function for save_inferior_ptid */ +/* Oft used ptids */ +ptid_t null_ptid; +ptid_t minus_one_ptid; + +/* Create a ptid given the necessary PID, LWP, and TID components. */ + +ptid_t +ptid_build (int pid, long lwp, long tid) +{ + ptid_t ptid; + + ptid.pid = pid; + ptid.lwp = lwp; + ptid.tid = tid; + return ptid; +} + +/* Create a ptid from just a pid. */ + +ptid_t +pid_to_ptid (int pid) +{ + return ptid_build (pid, 0, 0); +} + +/* Fetch the pid (process id) component from a ptid. */ + +int +ptid_get_pid (ptid_t ptid) +{ + return ptid.pid; +} + +/* Fetch the lwp (lightweight process) component from a ptid. */ + +long +ptid_get_lwp (ptid_t ptid) +{ + return ptid.lwp; +} + +/* Fetch the tid (thread id) component from a ptid. */ + +long +ptid_get_tid (ptid_t ptid) +{ + return ptid.tid; +} + +/* ptid_equal() is used to test equality of two ptids. */ + +int +ptid_equal (ptid_t ptid1, ptid_t ptid2) +{ + return (ptid1.pid == ptid2.pid && ptid1.lwp == ptid2.lwp + && ptid1.tid == ptid2.tid); +} + +/* restore_inferior_ptid() will be used by the cleanup machinery + to restore the inferior_ptid value saved in a call to + save_inferior_ptid(). */ static void restore_inferior_ptid (void *arg) @@ -4400,4 +4460,10 @@ instruction of that function. Otherwise, the function is skipped and\n\ the step command stops at a different source line.", &setlist); add_show_from_set (c, &showlist); + + /* ptid initializations */ + null_ptid = ptid_build (0, 0, 0); + minus_one_ptid = ptid_build (-1, 0, 0); + inferior_ptid = null_ptid; + target_last_wait_ptid = minus_one_ptid; } diff --git a/gdb/lin-lwp.c b/gdb/lin-lwp.c index 055ace7..6503331 100644 --- a/gdb/lin-lwp.c +++ b/gdb/lin-lwp.c @@ -102,18 +102,10 @@ static int num_lwps; static int threaded; -#ifndef TIDGET -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) -#endif - -#define THREAD_FLAG 0x80000000 -#define is_lwp(pid) (((pid) & THREAD_FLAG) == 0 && TIDGET (pid)) -#define GET_LWP(pid) TIDGET (pid) -#define GET_PID(pid) PIDGET (pid) -#define BUILD_LWP(tid, pid) MERGEPID (pid, tid) +#define GET_LWP(ptid) ptid_get_lwp (ptid) +#define GET_PID(ptid) ptid_get_pid (ptid) +#define is_lwp(ptid) (GET_LWP (ptid) != 0) +#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) #define is_cloned(pid) (GET_LWP (pid) != GET_PID (pid)) diff --git a/gdb/lin-thread.c b/gdb/lin-thread.c index 4e1ae7a..a14af7b 100644 --- a/gdb/lin-thread.c +++ b/gdb/lin-thread.c @@ -125,21 +125,25 @@ /* Prototypes for supply_gregset etc. */ #include "gregset.h" -#ifndef TIDGET -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) -#endif - /* Macros for superimposing PID and TID into inferior_ptid. */ -#define THREAD_FLAG 0x80000000 -#define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0) -#define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0) -#define GET_LWP(PID) TIDGET (PID) -#define GET_THREAD(PID) TIDGET (PID) -#define BUILD_LWP(TID, PID) MERGEPID (PID, TID) -#define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG) +#define GET_PID(ptid) ptid_get_pid (ptid) +#define GET_LWP(ptid) ptid_get_lwp (ptid) +#define GET_THREAD(ptid) ptid_get_tid (ptid) + +#define is_lwp(ptid) (GET_LWP (ptid) != 0) +#define is_thread(ptid) (GET_THREAD (ptid) != 0) + +#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) +#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid) + +/* From linux-thread.c. FIXME: These should go in a separate header + file, but I'm told that the life expectancy of lin-thread.c and + linux-thread.c isn't very long... */ + +extern int linux_child_wait (int, int *, int *); +extern void check_all_signal_numbers (void); +extern void linuxthreads_discard_global_state (void); +extern void attach_thread (int); /* * target_beneath is a pointer to the target_ops underlying this one. diff --git a/gdb/proc-service.c b/gdb/proc-service.c index 37ab1bd..c13929c 100644 --- a/gdb/proc-service.c +++ b/gdb/proc-service.c @@ -51,10 +51,6 @@ typedef size_t gdb_ps_size_t; /* Building process ids. */ -#ifndef MERGEPID -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) -#endif - #define BUILD_LWP(tid, pid) MERGEPID (pid, tid) diff --git a/gdb/procfs.c b/gdb/procfs.c index 53f0489..5a91ed8 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -315,18 +315,6 @@ typedef prstatus_t gdb_prstatus_t; typedef prstatus_t gdb_lwpstatus_t; #endif /* NEW_PROC_API */ - -/* Provide default composite pid manipulation macros for systems that - don't have threads. */ - -#ifndef PIDGET -#define PIDGET(PID) (PID) -#define TIDGET(PID) (PID) -#endif -#ifndef MERGEPID -#define MERGEPID(PID, TID) (PID) -#endif - typedef struct procinfo { struct procinfo *next; int pid; /* Process ID */ diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index cf8f33c..f92c49e 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -111,14 +111,15 @@ static void init_sol_core_ops (void); /* Default definitions: These must be defined in tm.h if they are to be shared with a process module such as procfs. */ -#define THREAD_FLAG 0x80000000 -#define is_thread(ARG) (((ARG) & THREAD_FLAG) != 0) -#define is_lwp(ARG) (((ARG) & THREAD_FLAG) == 0) -#define GET_LWP(PID) TIDGET (PID) -#define GET_THREAD(PID) TIDGET (PID) -#define BUILD_LWP(TID, PID) MERGEPID (PID, TID) - -#define BUILD_THREAD(TID, PID) (MERGEPID (PID, TID) | THREAD_FLAG) +#define GET_PID(ptid) ptid_get_pid (ptid) +#define GET_LWP(ptid) ptid_get_lwp (ptid) +#define GET_THREAD(ptid) ptid_get_tid (ptid) + +#define is_lwp(ptid) (GET_LWP (ptid) != 0) +#define is_thread(ptid) (GET_THREAD (ptid) != 0) + +#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) +#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid) /* Pointers to routines from lithread_db resolved by dlopen() */ diff --git a/gdb/thread-db.c b/gdb/thread-db.c index 2c2672a..a54f9fb 100644 --- a/gdb/thread-db.c +++ b/gdb/thread-db.c @@ -123,24 +123,17 @@ static void thread_db_find_new_threads (void); /* Building process ids. */ -#ifndef TIDGET -#define TIDGET(PID) (((PID) & 0x7fffffff) >> 16) -#define PIDGET0(PID) (((PID) & 0xffff)) -#define PIDGET(PID) ((PIDGET0 (PID) == 0xffff) ? -1 : PIDGET0 (PID)) -#define MERGEPID(PID, TID) (((PID) & 0xffff) | ((TID) << 16)) -#endif -#define THREAD_FLAG 0x80000000 +#define GET_PID(ptid) ptid_get_pid (ptid) +#define GET_LWP(ptid) ptid_get_lwp (ptid) +#define GET_THREAD(ptid) ptid_get_tid (ptid) -#define is_lwp(pid) (((pid) & THREAD_FLAG) == 0 && TIDGET (pid)) -#define is_thread(pid) ((pid) & THREAD_FLAG) +#define is_lwp(ptid) (GET_LWP (ptid) != 0) +#define is_thread(ptid) (GET_THREAD (ptid) != 0) -#define GET_PID(pid) PIDGET (pid) -#define GET_LWP(pid) TIDGET (pid) -#define GET_THREAD(pid) TIDGET (pid) +#define BUILD_LWP(lwp, pid) ptid_build (pid, lwp, 0) +#define BUILD_THREAD(tid, pid) ptid_build (pid, 0, tid) -#define BUILD_LWP(tid, pid) MERGEPID (pid, tid) -#define BUILD_THREAD(tid, pid) (MERGEPID (pid, tid) | THREAD_FLAG) struct private_thread_info -- cgit v1.1