This is the mail archive of the gdb-patches@sourceware.cygnus.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patches to allow GDB to use NEW_PROC_API on Solaris x86


These patches will allow GDB to use NEW_PROC_API on Solaris x86.

Currently GDB is not yet configured to use NEW_PROC_API, but it might be
in the future (I am making progress on hardware watchpoint support for
Solaris x86, which works only under the new API).

They clean up an old hack in sol-thread.c, which is no longer necessary
with the new procfs.c code (thanks a lot Michael Snyder, I assume that you
will have to approve these patches also).

The patches cause no testsuite regressions, with or without NEW_PROC_ABI
defined.

2000-02-28  Peter Schauer  <pes@regent.e-technik.tu-muenchen.de>

	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.

*** ./gdb/inferior.h.orig	Tue Nov  9 02:23:04 1999
--- ./gdb/inferior.h	Sat Feb 26 19:13:53 2000
***************
*** 224,231 ****
  
  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 **,
--- 224,229 ----
*** ./gdb/procfs.c.orig	Thu Feb 17 10:26:02 2000
--- ./gdb/procfs.c	Sat Feb 26 19:13:08 2000
***************
*** 5254,5273 ****
    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;
- }
--- 5254,5256 ----
*** ./gdb/sol-thread.c.orig	Thu Jan  6 04:06:42 2000
--- ./gdb/sol-thread.c	Sat Feb 26 18:58:37 2000
***************
*** 1318,1332 ****
  
  #ifdef TM_I386SOL2_H
  
- /* Get local descriptor table.  */
- 
- #include <sys/procfs.h>
- #include <sys/reg.h>
- #include <sys/sysi86.h>
- 
- static int nldt_allocated = 0;
- static struct ssd *ldt_bufp = NULL;
- 
  /* Reads the local descriptor table of a LWP.  */
  
  ps_err_e
--- 1318,1323 ----
***************
*** 1333,1378 ****
  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;
! 
!   if (ioctl (lwp_fd, PIOCNLDT, &nldt) == -1)
!     return PS_ERR;
! 
!   if (nldt_allocated < nldt)
      {
!       ldt_bufp
! 	= (struct ssd *) xrealloc (ldt_bufp, (nldt + 1) * sizeof (struct ssd));
!       nldt_allocated = nldt;
      }
! 
!   if (ioctl (lwp_fd, PIOCLDT, ldt_bufp) == -1)
      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 */
  
--- 1324,1341 ----
  ps_lgetLDT (gdb_ps_prochandle_t ph, lwpid_t lwpid,
  	    struct ssd *pldt)
  {
!   /* NOTE: only used on Solaris, therefore OK to refer to procfs.c */
!   extern struct ssd *procfs_find_LDT_entry (int);
!   struct ssd *ret;
  
!   ret = procfs_find_LDT_entry (BUILD_LWP (lwpid, PIDGET (inferior_pid)));
!   if (ret)
      {
!       memcpy (pldt, ret, sizeof (struct ssd));
!       return PS_OK;
      }
!   else	/* LDT not found. */
      return PS_ERR;
  }
  #endif /* TM_I386SOL2_H */
  

-- 
Peter Schauer			pes@regent.e-technik.tu-muenchen.de

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]