summaryrefslogtreecommitdiff
path: root/gdb/top.c
diff options
context:
space:
mode:
authorRichard Henderson <rth@redhat.com>2003-06-02 16:02:59 +0000
committerRichard Henderson <rth@redhat.com>2003-06-02 16:02:59 +0000
commit6dd77b815f4252948dae6b0a7e467789b09c6bbb (patch)
tree2776aa7f0c3036e5f302fffd78f1dc1c6b457026 /gdb/top.c
parentf6347e16334910d73f974b8b35092a979ddabb04 (diff)
downloadbinutils-gdb-6dd77b815f4252948dae6b0a7e467789b09c6bbb.tar.gz
* 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. * gdb.base/selftest.exp: Next over lim_at_start initialization.
Diffstat (limited to 'gdb/top.c')
-rw-r--r--gdb/top.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/gdb/top.c b/gdb/top.c
index fea71dfd87f..24410c4f53a 100644
--- 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",