Changes in procfs.c to fix bug with inferior's siginfo struct getting
authorFred Fish <fnf@specifix.com>
Wed, 1 Apr 1992 03:09:02 +0000 (03:09 +0000)
committerFred Fish <fnf@specifix.com>
Wed, 1 Apr 1992 03:09:02 +0000 (03:09 +0000)
needlessly stomped.  Changes in elfread.c and solib.c to fix DWARF
processing, broken by other recent changes.

gdb/elfread.c
gdb/procfs.c

index 3788fb4a23625c3c045a6dd03e5fdf5e5c864904..c2d133c62d2b39d36cf90c5b3270e2787aab47b6 100644 (file)
@@ -281,10 +281,19 @@ elf_symfile_read (objfile, addr, mainline)
   bfd *abfd = objfile->obfd;
   struct elfinfo ei;
   struct cleanup *back_to;
+  asection *text_sect;
 
   init_minimal_symbol_collection ();
   back_to = make_cleanup (discard_minimal_symbols, 0);
 
+  /* Compute the amount to relocate all symbols by.  The value passed in
+     as ADDR is typically either the actual address of the text section,
+     or a user specified address.  By subtracting off the actual address
+     of the text section, we can compute the relocation amount. */
+
+  text_sect = bfd_get_section_by_name (objfile -> obfd, ".text");
+  addr -= bfd_section_vma (objfile -> obfd, text_sect);
+
   /* Process the normal ELF symbol table first. */
 
   elf_symtab_read (abfd, addr, objfile);
index 04fed86cc06792a9920f79083c010954ece0c883..dc5ae10d1d4628d5aa42959813e2946f489246ca 100644 (file)
@@ -81,6 +81,9 @@ static struct procinfo pi;    /* Inferior's process information */
 
 /* Prototypes for local functions */
 
+static void
+set_proc_siginfo PARAMS ((struct procinfo *, int));
+
 static int
 proc_address_to_fd PARAMS ((CORE_ADDR, int));
 
@@ -759,15 +762,7 @@ detach (signal)
 {
   if (signal)
     {
-      struct siginfo siginfo;
-      siginfo.si_signo = signal;
-      siginfo.si_code = 0;
-      siginfo.si_errno = 0;
-      if (ioctl (pi.fd, PIOCSSIG, &siginfo) < 0)
-       {
-         print_sys_errmsg (pi.pathname, errno);
-         printf ("PIOCSSIG failed.\n");
-       }
+      set_proc_siginfo (&pi, signal);
     }
   if (ioctl (pi.fd, PIOCSEXIT, &pi.exitset) < 0)
     {
@@ -979,6 +974,76 @@ proc_wait (statloc)
 
 /*
 
+LOCAL FUNCTION
+
+       set_proc_siginfo - set a process's current signal info
+
+SYNOPSIS
+
+       void set_proc_siginfo (struct procinfo *pip, int signo);
+
+DESCRIPTION
+
+       Given a pointer to a process info struct in PIP and a signal number
+       in SIGNO, set the process's current signal and its associated signal
+       information.  The signal will be delivered to the process immediately
+       after execution is resumed, even if it is being held.  In addition,
+       this particular delivery will not cause another PR_SIGNALLED stop
+       even if the signal is being traced.
+
+       If we are not delivering the same signal that the prstatus siginfo
+       struct contains information about, then synthesize a siginfo struct
+       to match the signal we are doing to deliver, make it of the type
+       "generated by a user process", and send this synthesized copy.  When
+       used to set the inferior's signal state, this will be required if we
+       are not currently stopped because of a traced signal, or if we decide
+       to continue with a different signal.
+
+       Note that when continuing the inferior from a stop due to receipt
+       of a traced signal, we either have set PRCSIG to clear the existing
+       signal, or we have to call this function to do a PIOCSSIG with either
+       the existing siginfo struct from pr_info, or one we have synthesized
+       appropriately for the signal we want to deliver.  Otherwise if the
+       signal is still being traced, the inferior will immediately stop
+       again.
+
+       See siginfo(5) for more details.
+*/
+
+static void
+set_proc_siginfo (pip, signo)
+  struct procinfo *pip;
+  int signo;
+{
+  struct siginfo newsiginfo;
+  struct siginfo *sip;
+
+  if (pip -> valid)
+    {
+      if (signo == pip -> prstatus.pr_info.si_signo)
+       {
+         sip = &pip -> prstatus.pr_info;
+       }
+      else
+       {
+         (void) memset ((char *) &newsiginfo, 0, sizeof (newsiginfo));
+         sip = &newsiginfo;
+         sip -> si_signo = signo;
+         sip -> si_code = 0;
+         sip -> si_errno = 0;
+         sip -> si_pid = getpid ();
+         sip -> si_uid = getuid ();
+       }
+      if (ioctl (pip -> fd, PIOCSSIG, sip) < 0)
+       {
+         print_sys_errmsg (pip -> pathname, errno);
+         warning ("PIOCSSIG failed");
+       }
+    }
+}
+
+/*
+
 GLOBAL FUNCTION
 
        child_resume -- resume execution of the inferior process
@@ -1012,14 +1077,7 @@ child_resume (step, signal)
   pi.prrun.pr_vaddr = (caddr_t) *(int *) &registers[REGISTER_BYTE (PC_REGNUM)];
   if (signal)
     {
-      if (signal != pi.prstatus.pr_cursig)
-       {
-         struct siginfo siginfo;
-         siginfo.si_signo = signal;
-         siginfo.si_code = 0;
-         siginfo.si_errno = 0;
-         (void) ioctl (pi.fd, PIOCSSIG, &siginfo);
-       }
+      set_proc_siginfo (&pi, signal);
     }
   else
     {
This page took 0.028976 seconds and 4 git commands to generate.