gdb bug report

"David J. Roberts" <[email protected]>
Newsgroups gmane.comp.gdb.bugs.general
Message-ID <[email protected]>
There are a couple bugs with the Solaris port of gdb in the area of
signal handling.  

   )  gdb is mapping several different SIGNALS to SIGSEGV.  Instead of
      reporting the real error type.  Like SIGBUS and SIGILL.
   )  gdb is not properly setting up arguments for a registered signal
      handler.

I have been playing around a CVS checked out version of the code
(gdb-5.3).  The latest update was 12/18/02.  The configuration is for
sparc-sun-solaris2.8.

Below is the output from "cvs idff -c" on src/gdb/procfs.c
which shows the changes needed to fix the above mentioned bugs.

   --David Roberts


Index: procfs.c
===================================================================
RCS file: /cvs/src/src/gdb/procfs.c,v
retrieving revision 1.41
diff -c -r1.41 procfs.c
*** procfs.c	11 Sep 2002 00:13:58 -0000	1.41
--- procfs.c	19 Dec 2002 02:14:56 -0000
***************
*** 42,47 ****
--- 42,48 ----
  #include <sys/wait.h>
  #include <signal.h>
  #include <ctype.h>
+ #include <assert.h>
  
  /* 
   * PROCFS.C
***************
*** 669,675 ****
  static procinfo *
  create_procinfo (int pid, int tid)
  {
!   procinfo *pi, *parent;
  
    if ((pi = find_procinfo (pid, tid)))
      return pi;			/* Already exists, nothing to do. */
--- 670,676 ----
  static procinfo *
  create_procinfo (int pid, int tid)
  {
!   procinfo *pi, *parent = NULL;
  
    if ((pi = find_procinfo (pid, tid)))
      return pi;			/* Already exists, nothing to do. */
***************
*** 1339,1344 ****
--- 1340,1380 ----
  }
  
  /*
+  * Function: proc_cursig:
+  *
+  * returns the pr_cursig field (current signal).
+  */
+ 
+ 
+ int
+ proc_curilltrapno (struct procinfo *pi)
+ {
+   if (!pi->status_valid)
+     if (!proc_get_status (pi))
+       return 0;	/* FIXME: not a good failure value (but what is?) */
+ 
+ #ifdef NEW_PROC_API
+   return pi->prstatus.pr_lwp.pr_info.si_trapno;
+ #else
+   assert(0);
+ #endif
+ }
+ 
+ void *
+ proc_curilladdr (struct procinfo *pi)
+ {
+   if (!pi->status_valid)
+     if (!proc_get_status (pi))
+       return 0;	/* FIXME: not a good failure value (but what is?) */
+ 
+ #ifdef NEW_PROC_API
+   return pi->prstatus.pr_lwp.pr_info.si_addr;
+ #else
+   assert(0);
+ #endif
+ }
+ 
+ /*
   * Function: proc_modify_flag 
   *
   *  === I appologize for the messiness of this function. 
***************
*** 2497,2505 ****
    mysinfo = (gdb_siginfo_t *) &arg.sinfo;
    mysinfo->si_signo = signo;
    mysinfo->si_code  = 0;
    mysinfo->si_pid   = getpid ();       /* ?why? */
    mysinfo->si_uid   = getuid ();       /* ?why? */
! 
  #ifdef NEW_PROC_API
    arg.cmd = PCSSIG;
    win = (write (pi->ctl_fd, (void *) &arg, sizeof (arg))  == sizeof (arg));
--- 2533,2560 ----
    mysinfo = (gdb_siginfo_t *) &arg.sinfo;
    mysinfo->si_signo = signo;
    mysinfo->si_code  = 0;
+   switch(signo)
+ 					  
+   {
+ #ifdef SIGSEGV
+   case SIGSEGV:
+ 	  /* Need to setup trapno and address */
+ 	  mysinfo->si_trapno = proc_curilltrapno(pi);
+ 	  mysinfo->si_addr = proc_curilladdr(pi);
+ 	  break;
+ #endif
+ #ifdef SIGILL
+   case SIGILL:
+ 	  /* Need to setup trapno and address */
+ 	  mysinfo->si_trapno = proc_curilltrapno(pi);
+ 	  mysinfo->si_addr = proc_curilladdr(pi);
+ 	  break;
+ #endif
+   default:
    mysinfo->si_pid   = getpid ();       /* ?why? */
    mysinfo->si_uid   = getuid ();       /* ?why? */
!   break;
!   }
  #ifdef NEW_PROC_API
    arg.cmd = PCSSIG;
    win = (write (pi->ctl_fd, (void *) &arg, sizeof (arg))  == sizeof (arg));
***************
*** 4166,4173 ****
  #endif
  		  wstat = (SIGTRAP << 8) | 0177;
  		  break;
- 		case FLTSTACK:
  		case FLTACCESS:
  #if (FLTBOUNDS != FLTSTACK)	/* avoid "duplicate case" error */
  		case FLTBOUNDS:
  #endif
--- 4221,4230 ----
  #endif
  		  wstat = (SIGTRAP << 8) | 0177;
  		  break;
  		case FLTACCESS:
+ 		  wstat = (SIGBUS << 8) | 0177;
+ 		  break;
+ 		case FLTSTACK:
  #if (FLTBOUNDS != FLTSTACK)	/* avoid "duplicate case" error */
  		case FLTBOUNDS:
  #endif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.