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]

[RFA] rs6000-nat.c fix for large symtabs.



Some processes have more than 64 load segments; in the past gdb
would fail under these circumstances.  This patch should alleviate
that problem by expanding the buffer if the ld_info won't fit.

Fri Apr  7 13:44:38 2000  glen mccready  <gkm@pobox.com>

	* rs6000-nat.c (xcoff_relocate_symtab): Grow buffer if ptrace()
	  fails due to lack of space.

Index: rs6000-nat.c
===================================================================
retrieving revision 2.41.60.1
diff -c -b -r2.41.60.1 rs6000-nat.c
*** rs6000-nat.c	2000/02/14 04:31:53	2.41.60.1
--- rs6000-nat.c	2000/04/07 21:41:41
***************
*** 639,649 ****
  xcoff_relocate_symtab (pid)
       unsigned int pid;
  {
! #define	MAX_LOAD_SEGS 64	/* maximum number of load segments */
  
    struct ld_info *ldi;
  
!   ldi = (void *) alloca (MAX_LOAD_SEGS * sizeof (*ldi));
  
    /* According to my humble theory, AIX has some timing problems and
       when the user stack grows, kernel doesn't update stack info in time
--- 639,654 ----
  xcoff_relocate_symtab (pid)
       unsigned int pid;
  {
!   int load_segs = 64; /* number of load segments */
!   int rc;
  
+   do
+     {
    struct ld_info *ldi;
  
!       ldi = (void *) alloca (load_segs * sizeof (*ldi));
!       if (ldi == 0)
! 	perror_with_name ("xcoff_relocate_symtab");
  
    /* According to my humble theory, AIX has some timing problems and
       when the user stack grows, kernel doesn't update stack info in time
***************
*** 653,667 ****
    usleep (36000);
  
    errno = 0;
!   ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
! 	  MAX_LOAD_SEGS * sizeof (*ldi), (int *) ldi);
!   if (errno)
      perror_with_name ("ptrace ldinfo");
! 
    vmap_ldinfo (ldi);
! 
!   /* relocate the exec and core sections as well. */
!   vmap_exec ();
  }
  
  /* Core file stuff.  */
--- 658,678 ----
    usleep (36000);
  
    errno = 0;
!       rc = ptrace (PT_LDINFO, pid, (PTRACE_ARG3_TYPE) ldi,
! 	      load_segs * sizeof (*ldi), (int *) ldi);
!       if (rc == -1)
!         {
! 	if (errno == ENOMEM)
! 	  load_segs *= 2;
! 	else
      perror_with_name ("ptrace ldinfo");
!         }
!       else
! 	{
    vmap_ldinfo (ldi);
! 	  vmap_exec (); /* relocate the exec and core sections as well. */
! 	}
!     } while (rc == -1);
  }
  
  /* Core file stuff.  */

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