* top.h (lim_at_start): Declare.
authorRichard Henderson <rth@redhat.com>
Mon, 2 Jun 2003 16:02:59 +0000 (16:02 +0000)
committerRichard Henderson <rth@redhat.com>
Mon, 2 Jun 2003 16:02:59 +0000 (16:02 +0000)
        * main.c (captured_main): Set it.
        * top.c (lim_at_start): Define.
        (command_loop): Use it instead of &environ.
        * event-top.c (command_handler): Likewise.

        * gdb.base/selftest.exp: Next over lim_at_start initialization.

gdb/ChangeLog
gdb/event-top.c
gdb/main.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/selftest.exp
gdb/top.c
gdb/top.h

index a83c493c043e8590e120af746c966df7689fe49e..68cb29db1e3d5066593eca5abb113efd047f1d85 100644 (file)
@@ -1,3 +1,11 @@
+2003-06-02  Richard Henderson  <rth@redhat.com>
+
+       * top.h (lim_at_start): Declare.
+       * main.c (captured_main): Set it.
+       * top.c (lim_at_start): Define.
+       (command_loop): Use it instead of &environ.
+       * event-top.c (command_handler): Likewise.
+
 2003-06-01  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * mipsnbsd-tdep.c: Update copyright years.
index ceef7b9c9ebed9166000fec85c00edb5eb866ad1..5ab324df758839b04c34b8f5284f51d22d2ac172 100644 (file)
@@ -492,10 +492,8 @@ command_handler (char *command)
   if (display_space)
     {
 #ifdef HAVE_SBRK
-      extern char **environ;
       char *lim = (char *) sbrk (0);
-
-      space_at_cmd_start = (long) (lim - (char *) &environ);
+      space_at_cmd_start = lim - lim_at_start;
 #endif
     }
 
@@ -538,9 +536,8 @@ command_handler (char *command)
       if (display_space)
        {
 #ifdef HAVE_SBRK
-         extern char **environ;
          char *lim = (char *) sbrk (0);
-         long space_now = lim - (char *) &environ;
+         long space_now = lim - lim_at_start;
          long space_diff = space_now - space_at_cmd_start;
 
          printf_unfiltered ("Space used: %ld (%c%ld for this command)\n",
@@ -577,9 +574,8 @@ command_line_handler_continuation (struct continuation_arg *arg)
   if (display_space)
     {
 #ifdef HAVE_SBRK
-      extern char **environ;
       char *lim = (char *) sbrk (0);
-      long space_now = lim - (char *) &environ;
+      long space_now = lim - lim_at_start;
       long space_diff = space_now - space_at_cmd_start;
 
       printf_unfiltered ("Space used: %ld (%c%ld for this command)\n",
index fd25750b94e5306fbe189a91e73c499d8a4e4653..240aa00acfdb76bf2e80e3c8bb62b873169cd48d 100644 (file)
@@ -168,6 +168,10 @@ captured_main (void *data)
   /* This needs to happen before the first use of malloc.  */
   init_malloc (NULL);
 
+#ifdef HAVE_SBRK
+  lim_at_start = (char *) sbrk (0);
+#endif
+
 #if defined (ALIGN_STACK_ON_STARTUP)
   i = (int) &count & 0x3;
   if (i != 0)
index b4f4994f2ab7ef408b2abc95bdffa36a1343caea..6fd08ae86b25b9f1b0e43c2d134f54ca5e3285c5 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-02  Richard Henderson  <rth@redhat.com>
+
+       * gdb.base/selftest.exp: Next over lim_at_start initialization.
+
 2003-06-02  Richard Henderson  <rth@redhat.com>
 
        * gdb.base/dump.exp [alpha*-*-*]: Add -taso linker switch.
index 5d9419ed29862aa52aa921ff7196826e9efce0b5..a899e36011130dba63590702a5d3734f47e356f5 100644 (file)
@@ -115,6 +115,10 @@ proc do_steps_and_nexts {} {
                set description "next over init_malloc and everything it calls"
                set command "next"
            }
+           -re ".*lim_at_start.*$gdb_prompt $" {
+               set description "next over lim_at_start initialization"
+               set command "next"
+           }
            -re ".*count . 0x3.*$gdb_prompt $" {
                set description "next over conditional stack alignment code 1"
                set command "next"
index fea71dfd87f21b5cca27e2cf8d397791f322f1fd..24410c4f53a873045c212afec8b53e676cc6655e 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -171,6 +171,11 @@ int target_executing = 0;
 /* Level of control structure.  */
 static int control_level;
 
+/* Sbrk location on entry to main.  Used for statistics only.  */
+#ifdef HAVE_SBRK
+char *lim_at_start;
+#endif
+
 /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT.  */
 
 #ifndef STOP_SIGNAL
@@ -782,10 +787,8 @@ command_loop (void)
       if (display_space)
        {
 #ifdef HAVE_SBRK
-         extern char **environ;
          char *lim = (char *) sbrk (0);
-
-         space_at_cmd_start = (long) (lim - (char *) &environ);
+         space_at_cmd_start = lim - lim_at_start;
 #endif
        }
 
@@ -805,9 +808,8 @@ command_loop (void)
       if (display_space)
        {
 #ifdef HAVE_SBRK
-         extern char **environ;
          char *lim = (char *) sbrk (0);
-         long space_now = lim - (char *) &environ;
+         long space_now = lim - lim_at_start;
          long space_diff = space_now - space_at_cmd_start;
 
          printf_unfiltered ("Space used: %ld (%c%ld for this command)\n",
index ca0b3d13dc6c7c58e2727d67069c64f866fa4ed0..b103040325ebd2546722098e4b2e928276a80a38 100644 (file)
--- a/gdb/top.h
+++ b/gdb/top.h
@@ -70,5 +70,6 @@ extern char *source_error;
 extern char *source_pre_error;
 extern int history_expansion_p;
 extern int server_command;
+extern char *lim_at_start;
 
 #endif