From 05e28a7bbf77a063303591ea3ba713c7a990264f Mon Sep 17 00:00:00 2001 From: Andrew Cagney Date: Tue, 29 Feb 2000 13:53:59 +0000 Subject: [PATCH] From Peter Schauer: Fix Solaris/x86 threads by copying linux code. --- gdb/ChangeLog | 10 ++++++++++ gdb/inferior.h | 2 -- gdb/procfs.c | 17 ----------------- gdb/sol-thread.c | 53 ++++++++--------------------------------------------- 4 files changed, 18 insertions(+), 64 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 420316a..9f8b50c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,13 @@ +Wed Mar 1 00:49:06 2000 Andrew Cagney + + From 2000-02-28 Peter Schauer : + Make NEW_PROC_ABI interface functional on Solaris x86. + * sol-thread.c (ps_lgetLDT): Rewrite to use new + procfs_find_LDT_entry function from procfs.c, mostly copied from + lin-thread.c. + * inferior.h, procfs.c (procfs_get_pid_fd): Removed, no longer + needed. + Wed Mar 1 00:34:55 2000 Andrew Cagney From 2000-02-26 Peter Schauer : diff --git a/gdb/inferior.h b/gdb/inferior.h index 38c9ed6..5965f04 100644 --- a/gdb/inferior.h +++ b/gdb/inferior.h @@ -224,8 +224,6 @@ extern int proc_iterate_over_mappings PARAMS ((int (*)(int, CORE_ADDR))); extern int procfs_first_available PARAMS ((void)); -extern int procfs_get_pid_fd PARAMS ((int)); - /* From fork-child.c */ extern void fork_inferior PARAMS ((char *, char *, char **, diff --git a/gdb/procfs.c b/gdb/procfs.c index b108078..257de12 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -5254,20 +5254,3 @@ procfs_first_available () else return -1; } - -int -procfs_get_pid_fd (pid) - int pid; -{ - procinfo *pi; - - if (pid == -1 && inferior_pid != 0) - pi = find_procinfo (PIDGET (inferior_pid), 0); - else - pi = find_procinfo (PIDGET (pid), 0); - - if (pi) - return pi->ctl_fd; - else - return -1; -} diff --git a/gdb/sol-thread.c b/gdb/sol-thread.c index 71e9216..0ec10a4 100644 --- a/gdb/sol-thread.c +++ b/gdb/sol-thread.c @@ -1318,61 +1318,24 @@ ps_lsetfpregs (gdb_ps_prochandle_t ph, lwpid_t lwpid, #ifdef TM_I386SOL2_H -/* Get local descriptor table. */ - -#include -#include -#include - -static int nldt_allocated = 0; -static struct ssd *ldt_bufp = NULL; - /* Reads the local descriptor table of a LWP. */ ps_err_e ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid, struct ssd *pldt) { - gregset_t gregset; - int lwp_fd; - ps_err_e val; - int nldt; - int i; - - /* Get procfs file descriptor for the LWP. */ - lwp_fd = procfs_get_pid_fd (BUILD_LWP (lwpid, PIDGET (inferior_pid))); - if (lwp_fd < 0) - return PS_BADLID; - - /* Fetch registers und LDT descriptors. */ - if (ioctl (lwp_fd, PIOCGREG, &gregset) == -1) - return PS_ERR; + /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */ + extern struct ssd *procfs_find_LDT_entry (int); + struct ssd *ret; - if (ioctl (lwp_fd, PIOCNLDT, &nldt) == -1) - return PS_ERR; - - if (nldt_allocated < nldt) + ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_pid))); + if (ret) { - ldt_bufp - = (struct ssd *) xrealloc (ldt_bufp, (nldt + 1) * sizeof (struct ssd)); - nldt_allocated = nldt; + memcpy (pldt, ret, sizeof (struct ssd)); + return PS_OK; } - - if (ioctl (lwp_fd, PIOCLDT, ldt_bufp) == -1) + else /* LDT not found. */ return PS_ERR; - - /* Search LDT for the LWP via register GS. */ - for (i = 0; i < nldt; i++) - { - if (ldt_bufp[i].sel == (gregset[GS] & 0xffff)) - { - *pldt = ldt_bufp[i]; - return PS_OK; - } - } - - /* LDT not found. */ - return PS_ERR; } #endif /* TM_I386SOL2_H */ -- 2.7.4