This is the mail archive of the
gdb-patches@sourceware.cygnus.com
mailing list for the GDB project.
Re: [RFA] rs6000-nat.c fix for large symtabs.
- To: gkm at cygnus dot com (glen mccready)
- Subject: Re: [RFA] rs6000-nat.c fix for large symtabs.
- From: Kevin Buettner <kevinb at cygnus dot com>
- Date: Mon, 10 Apr 2000 17:24:22 -0700
- Cc: gdb-patches at sourceware dot cygnus dot com
- References: <200004102130.OAA15005@cygint.cygnus.com>
On Apr 10, 2:30pm, glen mccready wrote:
> Approval on this new patch?
Thanks for rewriting it to not use alloca(). My only request prior to
committing it is that you change the realloc() to xrealloc(). Once
you do this, you no longer need to check the return value.
(The real reason for this request, however, is to be consistent with
the rest of gdb. Also, xrealloc() does the right thing with a NULL
argument. Not all implementations of realloc() behave uniformly in
this regard.)
Kevin
> Index: rs6000-nat.c
> ===================================================================
> retrieving revision 2.41.60.1
> diff -c -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/10 20:14:33
> ***************
> *** 639,667 ****
> 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
> and ptrace calls step on user stack. That is why we sleep here a little,
> and give kernel to update its internals. */
> -
> - 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. */
> --- 639,679 ----
> xcoff_relocate_symtab (pid)
> unsigned int pid;
> {
> ! int load_segs = 64; /* number of load segments */
> ! int rc;
> ! struct ld_info *ldi = NULL;
> !
> ! do
> ! {
> ! ldi = (void *) realloc (ldi, load_segs * sizeof (*ldi));
> ! if (ldi == NULL)
> ! 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
> and ptrace calls step on user stack. That is why we sleep here a little,
> and give kernel to update its internals. */
>
> ! 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);
> ! if (ldi)
> ! free (ldi);
> }
>
> /* Core file stuff. */