From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24604 invoked by alias); 1 May 2002 13:54:12 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 24237 invoked from network); 1 May 2002 13:54:10 -0000 Received: from unknown (HELO cygnus.com) (205.180.83.203) by sources.redhat.com with SMTP; 1 May 2002 13:54:10 -0000 Received: from localhost.redhat.com (romulus.sfbay.redhat.com [172.16.27.251]) by runyon.cygnus.com (8.8.7-cygnus/8.8.7) with ESMTP id GAA14366; Wed, 1 May 2002 06:53:53 -0700 (PDT) Received: by localhost.redhat.com (Postfix, from userid 469) id DF8C710A8C; Wed, 1 May 2002 09:53:25 -0400 (EDT) From: Elena Zannoni MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <15567.62293.793109.926166@localhost.redhat.com> Date: Wed, 01 May 2002 06:54:00 -0000 To: fnf@redhat.com Cc: mec@shout.net (Michael Elizabeth Chastain), gdb-patches@sources.redhat.com Subject: Re: [RFA] Remove dependency on load address of environ In-Reply-To: <200205011323.g41DN5g05620@fred.ninemoons.com> References: <200204270214.g3R2EjZ26424@duracef.shout.net> <200205011323.g41DN5g05620@fred.ninemoons.com> X-SW-Source: 2002-05/txt/msg00001.txt.bz2 Fred Fish writes: > > I proofread this patch and it looks correct to me, no problems found. > > I have not tested it though. > > Peter Schauer found one problem with it, an sbrk not protected by HAVE_SBRK. Ah, I see, in main(). > Here is a revised patch. > Looks reasonable. Elena > -Fred > > Index: ChangeLog > =================================================================== > RCS file: /cvs/src/src/gdb/ChangeLog,v > retrieving revision 1.2546 > diff -c -p -r1.2546 ChangeLog > *** ChangeLog 1 May 2002 03:14:05 -0000 1.2546 > --- ChangeLog 1 May 2002 13:15:46 -0000 > *************** > *** 56,61 **** > --- 56,72 ---- > (ppc_sysv_abi_push_arguments): Handle vector parameters. > * ppc-tdep.h (ppc_sysv_abi_broken_use_struct_convention): Export. > > + 2002-04-26 Fred Fish > + > + * main.c (display_space_base): Add global variable. > + (main): Initialize display_space_base by calling sbrk. > + > + * main.c (captured_main): Add display_space_base decl, remove environ > + decl and reference, remove lim variable, use display_space_base. > + * top.c (command_loop): Ditto. > + * event-top.c (command_handler): Ditto. > + (command_line_handler_continuation): Ditto. > + > 2002-04-24 Pierre Muller > > * hpread.c (hpread_psymtab_to_symtab_1, > Index: top.c > =================================================================== > RCS file: /cvs/src/src/gdb/top.c,v > retrieving revision 1.62 > diff -c -p -r1.62 top.c > *** top.c 23 Apr 2002 03:00:57 -0000 1.62 > --- top.c 1 May 2002 13:15:48 -0000 > *************** command_loop (void) > *** 759,764 **** > --- 759,765 ---- > #endif > extern int display_time; > extern int display_space; > + extern char *display_space_base; > > while (instream && !feof (instream)) > { > *************** command_loop (void) > *** 782,791 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! > ! space_at_cmd_start = (long) (lim - (char *) &environ); > #endif > } > > --- 783,789 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! space_at_cmd_start = (char *) sbrk (0) - display_space_base; > #endif > } > > *************** command_loop (void) > *** 805,813 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! long space_now = lim - (char *) &environ; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > --- 803,809 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! long space_now = (char *) sbrk (0) - display_space_base; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > Index: event-top.c > =================================================================== > RCS file: /cvs/src/src/gdb/event-top.c,v > retrieving revision 1.20 > diff -c -p -r1.20 event-top.c > *** event-top.c 27 Mar 2002 21:20:15 -0000 1.20 > --- event-top.c 1 May 2002 13:15:51 -0000 > *************** command_handler (char *command) > *** 475,480 **** > --- 475,481 ---- > #endif > extern int display_time; > extern int display_space; > + extern char *display_space_base; > > quit_flag = 0; > if (instream == stdin && stdin_is_tty) > *************** command_handler (char *command) > *** 494,503 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! > ! space_at_cmd_start = (long) (lim - (char *) &environ); > #endif > } > > --- 495,501 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! space_at_cmd_start = (char *) sbrk (0) - display_space_base; > #endif > } > > *************** command_handler (char *command) > *** 538,546 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! long space_now = lim - (char *) &environ; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > --- 536,542 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! long space_now = (char *) sbrk (0) - display_space_base; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > *************** command_line_handler_continuation (struc > *** 560,565 **** > --- 556,562 ---- > { > extern int display_time; > extern int display_space; > + extern char *display_space_base; > > long time_at_cmd_start = arg->data.longint; > long space_at_cmd_start = arg->next->data.longint; > *************** command_line_handler_continuation (struc > *** 577,585 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! long space_now = lim - (char *) &environ; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > --- 574,580 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! long space_now = (char *) sbrk (0) - display_space_base; > long space_diff = space_now - space_at_cmd_start; > > printf_unfiltered ("Space used: %ld (%c%ld for this command)\n", > Index: main.c > =================================================================== > RCS file: /cvs/src/src/gdb/main.c,v > retrieving revision 1.16 > diff -c -p -r1.16 main.c > *** main.c 17 Jan 2002 22:15:17 -0000 1.16 > --- main.c 1 May 2002 13:15:52 -0000 > *************** int display_time; > *** 45,50 **** > --- 45,54 ---- > > int display_space; > > + /* Remember the lowest sbrk limit when display_space is nonzero. */ > + > + char *display_space_base; > + > /* Whether this is the async version or not. The async version is > invoked on the command line with the -nw --async options. In this > version, the usual command_loop is substituted by and event loop which > *************** extern int gdbtk_test (char *); > *** 679,689 **** > if (display_space) > { > #ifdef HAVE_SBRK > ! extern char **environ; > ! char *lim = (char *) sbrk (0); > ! > ! printf_unfiltered ("Startup size: data size %ld\n", > ! (long) (lim - (char *) &environ)); > #endif > } > > --- 683,690 ---- > if (display_space) > { > #ifdef HAVE_SBRK > ! long space_now = (char *) sbrk (0) - display_space_base; > ! printf_unfiltered ("Startup size: data size %ld\n", space_now); > #endif > } > > *************** main (int argc, char **argv) > *** 731,736 **** > --- 732,740 ---- > struct captured_main_args args; > args.argc = argc; > args.argv = argv; > + #ifdef HAVE_SBRK > + display_space_base = sbrk (0); > + #endif > catch_errors (captured_main, &args, "", RETURN_MASK_ALL); > return 0; > }