]> Git Repo - binutils.git/blob - gdb/utils.c
* gdb.t17/callfuncs.exp: More comments about t_func_values tests.
[binutils.git] / gdb / utils.c
1 /* General utility routines for GDB, the GNU debugger.
2    Copyright 1986, 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
3
4 This file is part of GDB.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
19
20 #include "defs.h"
21 #if !defined(__GO32__)
22 #include <sys/ioctl.h>
23 #include <sys/param.h>
24 #include <pwd.h>
25 #endif
26 #include <varargs.h>
27 #include <ctype.h>
28 #include <string.h>
29
30 #include "signals.h"
31 #include "gdbcmd.h"
32 #include "serial.h"
33 #include "terminal.h" /* For job_control */
34 #include "bfd.h"
35 #include "target.h"
36 #include "demangle.h"
37 #include "expression.h"
38 #include "language.h"
39
40 /* Prototypes for local functions */
41
42 #if defined (NO_MMALLOC) || defined (NO_MMALLOC_CHECK)
43 #else
44
45 static void
46 malloc_botch PARAMS ((void));
47
48 #endif /* NO_MMALLOC, etc */
49
50 static void
51 fatal_dump_core ();     /* Can't prototype with <varargs.h> usage... */
52
53 static void
54 prompt_for_continue PARAMS ((void));
55
56 static void 
57 set_width_command PARAMS ((char *, int, struct cmd_list_element *));
58
59 /* If this definition isn't overridden by the header files, assume
60    that isatty and fileno exist on this system.  */
61 #ifndef ISATTY
62 #define ISATTY(FP)      (isatty (fileno (FP)))
63 #endif
64
65 /* Chain of cleanup actions established with make_cleanup,
66    to be executed if an error happens.  */
67
68 static struct cleanup *cleanup_chain;
69
70 /* Nonzero means a quit has been requested.  */
71
72 int quit_flag;
73
74 /* Nonzero means quit immediately if Control-C is typed now, rather
75    than waiting until QUIT is executed.  Be careful in setting this;
76    code which executes with immediate_quit set has to be very careful
77    about being able to deal with being interrupted at any time.  It is
78    almost always better to use QUIT; the only exception I can think of
79    is being able to quit out of a system call (using EINTR loses if
80    the SIGINT happens between the previous QUIT and the system call).
81    To immediately quit in the case in which a SIGINT happens between
82    the previous QUIT and setting immediate_quit (desirable anytime we
83    expect to block), call QUIT after setting immediate_quit.  */
84
85 int immediate_quit;
86
87 /* Nonzero means that encoded C++ names should be printed out in their
88    C++ form rather than raw.  */
89
90 int demangle = 1;
91
92 /* Nonzero means that encoded C++ names should be printed out in their
93    C++ form even in assembler language displays.  If this is set, but
94    DEMANGLE is zero, names are printed raw, i.e. DEMANGLE controls.  */
95
96 int asm_demangle = 0;
97
98 /* Nonzero means that strings with character values >0x7F should be printed
99    as octal escapes.  Zero means just print the value (e.g. it's an
100    international character, and the terminal or window can cope.)  */
101
102 int sevenbit_strings = 0;
103
104 /* String to be printed before error messages, if any.  */
105
106 char *error_pre_print;
107 char *warning_pre_print = "\nwarning: ";
108 \f
109 /* Add a new cleanup to the cleanup_chain,
110    and return the previous chain pointer
111    to be passed later to do_cleanups or discard_cleanups.
112    Args are FUNCTION to clean up with, and ARG to pass to it.  */
113
114 struct cleanup *
115 make_cleanup (function, arg)
116      void (*function) PARAMS ((PTR));
117      PTR arg;
118 {
119   register struct cleanup *new
120     = (struct cleanup *) xmalloc (sizeof (struct cleanup));
121   register struct cleanup *old_chain = cleanup_chain;
122
123   new->next = cleanup_chain;
124   new->function = function;
125   new->arg = arg;
126   cleanup_chain = new;
127
128   return old_chain;
129 }
130
131 /* Discard cleanups and do the actions they describe
132    until we get back to the point OLD_CHAIN in the cleanup_chain.  */
133
134 void
135 do_cleanups (old_chain)
136      register struct cleanup *old_chain;
137 {
138   register struct cleanup *ptr;
139   while ((ptr = cleanup_chain) != old_chain)
140     {
141       cleanup_chain = ptr->next;        /* Do this first incase recursion */
142       (*ptr->function) (ptr->arg);
143       free (ptr);
144     }
145 }
146
147 /* Discard cleanups, not doing the actions they describe,
148    until we get back to the point OLD_CHAIN in the cleanup_chain.  */
149
150 void
151 discard_cleanups (old_chain)
152      register struct cleanup *old_chain;
153 {
154   register struct cleanup *ptr;
155   while ((ptr = cleanup_chain) != old_chain)
156     {
157       cleanup_chain = ptr->next;
158       free ((PTR)ptr);
159     }
160 }
161
162 /* Set the cleanup_chain to 0, and return the old cleanup chain.  */
163 struct cleanup *
164 save_cleanups ()
165 {
166   struct cleanup *old_chain = cleanup_chain;
167
168   cleanup_chain = 0;
169   return old_chain;
170 }
171
172 /* Restore the cleanup chain from a previously saved chain.  */
173 void
174 restore_cleanups (chain)
175      struct cleanup *chain;
176 {
177   cleanup_chain = chain;
178 }
179
180 /* This function is useful for cleanups.
181    Do
182
183      foo = xmalloc (...);
184      old_chain = make_cleanup (free_current_contents, &foo);
185
186    to arrange to free the object thus allocated.  */
187
188 void
189 free_current_contents (location)
190      char **location;
191 {
192   free (*location);
193 }
194
195 /* Provide a known function that does nothing, to use as a base for
196    for a possibly long chain of cleanups.  This is useful where we
197    use the cleanup chain for handling normal cleanups as well as dealing
198    with cleanups that need to be done as a result of a call to error().
199    In such cases, we may not be certain where the first cleanup is, unless
200    we have a do-nothing one to always use as the base. */
201
202 /* ARGSUSED */
203 void
204 null_cleanup (arg)
205     char **arg;
206 {
207 }
208
209 \f
210 /* Provide a hook for modules wishing to print their own warning messages
211    to set up the terminal state in a compatible way, without them having
212    to import all the target_<...> macros. */
213
214 void
215 warning_setup ()
216 {
217   target_terminal_ours ();
218   wrap_here("");                        /* Force out any buffered output */
219   gdb_flush (gdb_stdout);
220 }
221
222 /* Print a warning message.
223    The first argument STRING is the warning message, used as a fprintf string,
224    and the remaining args are passed as arguments to it.
225    The primary difference between warnings and errors is that a warning
226    does not force the return to command level. */
227
228 /* VARARGS */
229 void
230 warning (va_alist)
231      va_dcl
232 {
233   va_list args;
234   char *string;
235
236   va_start (args);
237   target_terminal_ours ();
238   wrap_here("");                        /* Force out any buffered output */
239   gdb_flush (gdb_stdout);
240   if (warning_pre_print)
241     fprintf_unfiltered (gdb_stderr, warning_pre_print);
242   string = va_arg (args, char *);
243   vfprintf_unfiltered (gdb_stderr, string, args);
244   fprintf_unfiltered (gdb_stderr, "\n");
245   va_end (args);
246 }
247
248 /* Print an error message and return to command level.
249    The first argument STRING is the error message, used as a fprintf string,
250    and the remaining args are passed as arguments to it.  */
251
252 /* VARARGS */
253 NORETURN void
254 error (va_alist)
255      va_dcl
256 {
257   va_list args;
258   char *string;
259
260   va_start (args);
261   target_terminal_ours ();
262   wrap_here("");                        /* Force out any buffered output */
263   gdb_flush (gdb_stdout);
264   if (error_pre_print)
265     fprintf_filtered (gdb_stderr, error_pre_print);
266   string = va_arg (args, char *);
267   vfprintf_filtered (gdb_stderr, string, args);
268   fprintf_filtered (gdb_stderr, "\n");
269   va_end (args);
270   return_to_top_level (RETURN_ERROR);
271 }
272
273 /* Print an error message and exit reporting failure.
274    This is for a error that we cannot continue from.
275    The arguments are printed a la printf.
276
277    This function cannot be declared volatile (NORETURN) in an
278    ANSI environment because exit() is not declared volatile. */
279
280 /* VARARGS */
281 NORETURN void
282 fatal (va_alist)
283      va_dcl
284 {
285   va_list args;
286   char *string;
287
288   va_start (args);
289   string = va_arg (args, char *);
290   fprintf_unfiltered (gdb_stderr, "\ngdb: ");
291   vfprintf_unfiltered (gdb_stderr, string, args);
292   fprintf_unfiltered (gdb_stderr, "\n");
293   va_end (args);
294   exit (1);
295 }
296
297 /* Print an error message and exit, dumping core.
298    The arguments are printed a la printf ().  */
299
300 /* VARARGS */
301 static void
302 fatal_dump_core (va_alist)
303      va_dcl
304 {
305   va_list args;
306   char *string;
307
308   va_start (args);
309   string = va_arg (args, char *);
310   /* "internal error" is always correct, since GDB should never dump
311      core, no matter what the input.  */
312   fprintf_unfiltered (gdb_stderr, "\ngdb internal error: ");
313   vfprintf_unfiltered (gdb_stderr, string, args);
314   fprintf_unfiltered (gdb_stderr, "\n");
315   va_end (args);
316
317   signal (SIGQUIT, SIG_DFL);
318   kill (getpid (), SIGQUIT);
319   /* We should never get here, but just in case...  */
320   exit (1);
321 }
322
323 /* The strerror() function can return NULL for errno values that are
324    out of range.  Provide a "safe" version that always returns a
325    printable string. */
326
327 char *
328 safe_strerror (errnum)
329      int errnum;
330 {
331   char *msg;
332   static char buf[32];
333
334   if ((msg = strerror (errnum)) == NULL)
335     {
336       sprintf (buf, "(undocumented errno %d)", errnum);
337       msg = buf;
338     }
339   return (msg);
340 }
341
342 /* The strsignal() function can return NULL for signal values that are
343    out of range.  Provide a "safe" version that always returns a
344    printable string. */
345
346 char *
347 safe_strsignal (signo)
348      int signo;
349 {
350   char *msg;
351   static char buf[32];
352
353   if ((msg = strsignal (signo)) == NULL)
354     {
355       sprintf (buf, "(undocumented signal %d)", signo);
356       msg = buf;
357     }
358   return (msg);
359 }
360
361
362 /* Print the system error message for errno, and also mention STRING
363    as the file name for which the error was encountered.
364    Then return to command level.  */
365
366 void
367 perror_with_name (string)
368      char *string;
369 {
370   char *err;
371   char *combined;
372
373   err = safe_strerror (errno);
374   combined = (char *) alloca (strlen (err) + strlen (string) + 3);
375   strcpy (combined, string);
376   strcat (combined, ": ");
377   strcat (combined, err);
378
379   /* I understand setting these is a matter of taste.  Still, some people
380      may clear errno but not know about bfd_error.  Doing this here is not
381      unreasonable. */
382   bfd_set_error (bfd_error_no_error);
383   errno = 0;
384
385   error ("%s.", combined);
386 }
387
388 /* Print the system error message for ERRCODE, and also mention STRING
389    as the file name for which the error was encountered.  */
390
391 void
392 print_sys_errmsg (string, errcode)
393      char *string;
394      int errcode;
395 {
396   char *err;
397   char *combined;
398
399   err = safe_strerror (errcode);
400   combined = (char *) alloca (strlen (err) + strlen (string) + 3);
401   strcpy (combined, string);
402   strcat (combined, ": ");
403   strcat (combined, err);
404
405   /* We want anything which was printed on stdout to come out first, before
406      this message.  */
407   gdb_flush (gdb_stdout);
408   fprintf_unfiltered (gdb_stderr, "%s.\n", combined);
409 }
410
411 /* Control C eventually causes this to be called, at a convenient time.  */
412
413 void
414 quit ()
415 {
416   serial_t gdb_stdout_serial = serial_fdopen (1);
417
418   target_terminal_ours ();
419
420   /* We want all output to appear now, before we print "Quit".  We
421      have 3 levels of buffering we have to flush (it's possible that
422      some of these should be changed to flush the lower-level ones
423      too):  */
424
425   /* 1.  The _filtered buffer.  */
426   wrap_here ((char *)0);
427
428   /* 2.  The stdio buffer.  */
429   gdb_flush (gdb_stdout);
430   gdb_flush (gdb_stderr);
431
432   /* 3.  The system-level buffer.  */
433   SERIAL_FLUSH_OUTPUT (gdb_stdout_serial);
434   SERIAL_UN_FDOPEN (gdb_stdout_serial);
435
436   /* Don't use *_filtered; we don't want to prompt the user to continue.  */
437   if (error_pre_print)
438     fprintf_unfiltered (gdb_stderr, error_pre_print);
439
440   if (job_control
441       /* If there is no terminal switching for this target, then we can't
442          possibly get screwed by the lack of job control.  */
443       || current_target->to_terminal_ours == NULL)
444     fprintf_unfiltered (gdb_stderr, "Quit\n");
445   else
446     fprintf_unfiltered (gdb_stderr,
447              "Quit (expect signal SIGINT when the program is resumed)\n");
448   return_to_top_level (RETURN_QUIT);
449 }
450
451
452 #ifdef __GO32__
453
454 /* In the absence of signals, poll keyboard for a quit.
455    Called from #define QUIT pollquit() in xm-go32.h. */
456
457 void
458 pollquit()
459 {
460   if (kbhit ())
461     {
462       int k = getkey ();
463       if (k == 1) {
464         quit_flag = 1;
465         quit();
466       }
467       else if (k == 2) {
468         immediate_quit = 1;
469         quit ();
470       }
471       else 
472         {
473           /* We just ignore it */
474           fprintf_unfiltered (gdb_stderr, "CTRL-A to quit, CTRL-B to quit harder\n");
475         }
476     }
477 }
478
479
480 #endif
481 #ifdef __GO32__
482 void notice_quit()
483 {
484   if (kbhit ())
485     {
486       int k = getkey ();
487       if (k == 1) {
488         quit_flag = 1;
489       }
490       else if (k == 2)
491         {
492           immediate_quit = 1;
493         }
494       else 
495         {
496           fprintf_unfiltered (gdb_stderr, "CTRL-A to quit, CTRL-B to quit harder\n");
497         }
498     }
499 }
500 #else
501 void notice_quit()
502 {
503   /* Done by signals */
504 }
505 #endif
506 /* Control C comes here */
507
508 void
509 request_quit (signo)
510      int signo;
511 {
512   quit_flag = 1;
513
514   /* Restore the signal handler.  Harmless with BSD-style signals, needed
515      for System V-style signals.  So just always do it, rather than worrying
516      about USG defines and stuff like that.  */
517   signal (signo, request_quit);
518
519   if (immediate_quit)
520     quit ();
521 }
522
523 \f
524 /* Memory management stuff (malloc friends).  */
525
526 #if defined (NO_MMALLOC)
527
528 PTR
529 mmalloc (md, size)
530      PTR md;
531      long size;
532 {
533   return (malloc (size));
534 }
535
536 PTR
537 mrealloc (md, ptr, size)
538      PTR md;
539      PTR ptr;
540      long size;
541 {
542   if (ptr == 0)         /* Guard against old realloc's */
543     return malloc (size);
544   else
545     return realloc (ptr, size);
546 }
547
548 void
549 mfree (md, ptr)
550      PTR md;
551      PTR ptr;
552 {
553   free (ptr);
554 }
555
556 #endif  /* NO_MMALLOC */
557
558 #if defined (NO_MMALLOC) || defined (NO_MMALLOC_CHECK)
559
560 void
561 init_malloc (md)
562      PTR md;
563 {
564 }
565
566 #else /* have mmalloc and want corruption checking  */
567
568 static void
569 malloc_botch ()
570 {
571   fatal_dump_core ("Memory corruption");
572 }
573
574 /* Attempt to install hooks in mmalloc/mrealloc/mfree for the heap specified
575    by MD, to detect memory corruption.  Note that MD may be NULL to specify
576    the default heap that grows via sbrk.
577
578    Note that for freshly created regions, we must call mmcheck prior to any
579    mallocs in the region.  Otherwise, any region which was allocated prior to
580    installing the checking hooks, which is later reallocated or freed, will
581    fail the checks!  The mmcheck function only allows initial hooks to be
582    installed before the first mmalloc.  However, anytime after we have called
583    mmcheck the first time to install the checking hooks, we can call it again
584    to update the function pointer to the memory corruption handler.
585
586    Returns zero on failure, non-zero on success. */
587
588 void
589 init_malloc (md)
590      PTR md;
591 {
592   if (!mmcheck (md, malloc_botch))
593     {
594       warning ("internal error: failed to install memory consistency checks");
595     }
596
597   mmtrace ();
598 }
599
600 #endif /* Have mmalloc and want corruption checking  */
601
602 /* Called when a memory allocation fails, with the number of bytes of
603    memory requested in SIZE. */
604
605 NORETURN void
606 nomem (size)
607      long size;
608 {
609   if (size > 0)
610     {
611       fatal ("virtual memory exhausted: can't allocate %ld bytes.", size);
612     }
613   else
614     {
615       fatal ("virtual memory exhausted.");
616     }
617 }
618
619 /* Like mmalloc but get error if no storage available, and protect against
620    the caller wanting to allocate zero bytes.  Whether to return NULL for
621    a zero byte request, or translate the request into a request for one
622    byte of zero'd storage, is a religious issue. */
623
624 PTR
625 xmmalloc (md, size)
626      PTR md;
627      long size;
628 {
629   register PTR val;
630
631   if (size == 0)
632     {
633       val = NULL;
634     }
635   else if ((val = mmalloc (md, size)) == NULL)
636     {
637       nomem (size);
638     }
639   return (val);
640 }
641
642 /* Like mrealloc but get error if no storage available.  */
643
644 PTR
645 xmrealloc (md, ptr, size)
646      PTR md;
647      PTR ptr;
648      long size;
649 {
650   register PTR val;
651
652   if (ptr != NULL)
653     {
654       val = mrealloc (md, ptr, size);
655     }
656   else
657     {
658       val = mmalloc (md, size);
659     }
660   if (val == NULL)
661     {
662       nomem (size);
663     }
664   return (val);
665 }
666
667 /* Like malloc but get error if no storage available, and protect against
668    the caller wanting to allocate zero bytes.  */
669
670 PTR
671 xmalloc (size)
672      long size;
673 {
674   return (xmmalloc ((PTR) NULL, size));
675 }
676
677 /* Like mrealloc but get error if no storage available.  */
678
679 PTR
680 xrealloc (ptr, size)
681      PTR ptr;
682      long size;
683 {
684   return (xmrealloc ((PTR) NULL, ptr, size));
685 }
686
687 \f
688 /* My replacement for the read system call.
689    Used like `read' but keeps going if `read' returns too soon.  */
690
691 int
692 myread (desc, addr, len)
693      int desc;
694      char *addr;
695      int len;
696 {
697   register int val;
698   int orglen = len;
699
700   while (len > 0)
701     {
702       val = read (desc, addr, len);
703       if (val < 0)
704         return val;
705       if (val == 0)
706         return orglen - len;
707       len -= val;
708       addr += val;
709     }
710   return orglen;
711 }
712 \f
713 /* Make a copy of the string at PTR with SIZE characters
714    (and add a null character at the end in the copy).
715    Uses malloc to get the space.  Returns the address of the copy.  */
716
717 char *
718 savestring (ptr, size)
719      const char *ptr;
720      int size;
721 {
722   register char *p = (char *) xmalloc (size + 1);
723   memcpy (p, ptr, size);
724   p[size] = 0;
725   return p;
726 }
727
728 char *
729 msavestring (md, ptr, size)
730      PTR md;
731      const char *ptr;
732      int size;
733 {
734   register char *p = (char *) xmmalloc (md, size + 1);
735   memcpy (p, ptr, size);
736   p[size] = 0;
737   return p;
738 }
739
740 /* The "const" is so it compiles under DGUX (which prototypes strsave
741    in <string.h>.  FIXME: This should be named "xstrsave", shouldn't it?
742    Doesn't real strsave return NULL if out of memory?  */
743 char *
744 strsave (ptr)
745      const char *ptr;
746 {
747   return savestring (ptr, strlen (ptr));
748 }
749
750 char *
751 mstrsave (md, ptr)
752      PTR md;
753      const char *ptr;
754 {
755   return (msavestring (md, ptr, strlen (ptr)));
756 }
757
758 void
759 print_spaces (n, file)
760      register int n;
761      register FILE *file;
762 {
763   while (n-- > 0)
764     fputc (' ', file);
765 }
766
767 /* Print a host address.  */
768
769 void
770 gdb_print_address (addr, stream)
771      PTR addr;
772      GDB_FILE *stream;
773 {
774
775   /* We could use the %p conversion specifier to fprintf if we had any
776      way of knowing whether this host supports it.  But the following
777      should work on the Alpha and on 32 bit machines.  */
778
779   fprintf_filtered (stream, "0x%lx", (unsigned long)addr);
780 }
781
782 /* Ask user a y-or-n question and return 1 iff answer is yes.
783    Takes three args which are given to printf to print the question.
784    The first, a control string, should end in "? ".
785    It should not say how to answer, because we do that.  */
786
787 /* VARARGS */
788 int
789 query (va_alist)
790      va_dcl
791 {
792   va_list args;
793   char *ctlstr;
794   register int answer;
795   register int ans2;
796
797   /* Automatically answer "yes" if input is not from a terminal.  */
798   if (!input_from_terminal_p ())
799     return 1;
800
801   while (1)
802     {
803       wrap_here ("");           /* Flush any buffered output */
804       gdb_flush (gdb_stdout);
805       va_start (args);
806       ctlstr = va_arg (args, char *);
807       vfprintf_filtered (gdb_stdout, ctlstr, args);
808       va_end (args);
809       printf_filtered ("(y or n) ");
810       gdb_flush (gdb_stdout);
811       answer = fgetc (stdin);
812       clearerr (stdin);         /* in case of C-d */
813       if (answer == EOF)        /* C-d */
814         return 1;
815       if (answer != '\n')       /* Eat rest of input line, to EOF or newline */
816         do 
817           {
818             ans2 = fgetc (stdin);
819             clearerr (stdin);
820           }
821         while (ans2 != EOF && ans2 != '\n');
822       if (answer >= 'a')
823         answer -= 040;
824       if (answer == 'Y')
825         return 1;
826       if (answer == 'N')
827         return 0;
828       printf_filtered ("Please answer y or n.\n");
829     }
830 }
831
832 \f
833 /* Parse a C escape sequence.  STRING_PTR points to a variable
834    containing a pointer to the string to parse.  That pointer
835    should point to the character after the \.  That pointer
836    is updated past the characters we use.  The value of the
837    escape sequence is returned.
838
839    A negative value means the sequence \ newline was seen,
840    which is supposed to be equivalent to nothing at all.
841
842    If \ is followed by a null character, we return a negative
843    value and leave the string pointer pointing at the null character.
844
845    If \ is followed by 000, we return 0 and leave the string pointer
846    after the zeros.  A value of 0 does not mean end of string.  */
847
848 int
849 parse_escape (string_ptr)
850      char **string_ptr;
851 {
852   register int c = *(*string_ptr)++;
853   switch (c)
854     {
855     case 'a':
856       return 007;               /* Bell (alert) char */
857     case 'b':
858       return '\b';
859     case 'e':                   /* Escape character */
860       return 033;
861     case 'f':
862       return '\f';
863     case 'n':
864       return '\n';
865     case 'r':
866       return '\r';
867     case 't':
868       return '\t';
869     case 'v':
870       return '\v';
871     case '\n':
872       return -2;
873     case 0:
874       (*string_ptr)--;
875       return 0;
876     case '^':
877       c = *(*string_ptr)++;
878       if (c == '\\')
879         c = parse_escape (string_ptr);
880       if (c == '?')
881         return 0177;
882       return (c & 0200) | (c & 037);
883       
884     case '0':
885     case '1':
886     case '2':
887     case '3':
888     case '4':
889     case '5':
890     case '6':
891     case '7':
892       {
893         register int i = c - '0';
894         register int count = 0;
895         while (++count < 3)
896           {
897             if ((c = *(*string_ptr)++) >= '0' && c <= '7')
898               {
899                 i *= 8;
900                 i += c - '0';
901               }
902             else
903               {
904                 (*string_ptr)--;
905                 break;
906               }
907           }
908         return i;
909       }
910     default:
911       return c;
912     }
913 }
914 \f
915 /* Print the character C on STREAM as part of the contents of a literal
916    string whose delimiter is QUOTER.  Note that this routine should only
917    be call for printing things which are independent of the language
918    of the program being debugged. */
919
920 void
921 gdb_printchar (c, stream, quoter)
922      register int c;
923      FILE *stream;
924      int quoter;
925 {
926
927   c &= 0xFF;                    /* Avoid sign bit follies */
928
929   if (              c < 0x20  ||                /* Low control chars */ 
930       (c >= 0x7F && c < 0xA0) ||                /* DEL, High controls */
931       (sevenbit_strings && c >= 0x80)) {        /* high order bit set */
932     switch (c)
933       {
934       case '\n':
935         fputs_filtered ("\\n", stream);
936         break;
937       case '\b':
938         fputs_filtered ("\\b", stream);
939         break;
940       case '\t':
941         fputs_filtered ("\\t", stream);
942         break;
943       case '\f':
944         fputs_filtered ("\\f", stream);
945         break;
946       case '\r':
947         fputs_filtered ("\\r", stream);
948         break;
949       case '\033':
950         fputs_filtered ("\\e", stream);
951         break;
952       case '\007':
953         fputs_filtered ("\\a", stream);
954         break;
955       default:
956         fprintf_filtered (stream, "\\%.3o", (unsigned int) c);
957         break;
958       }
959   } else {
960     if (c == '\\' || c == quoter)
961       fputs_filtered ("\\", stream);
962     fprintf_filtered (stream, "%c", c);
963   }
964 }
965 \f
966 /* Number of lines per page or UINT_MAX if paging is disabled.  */
967 static unsigned int lines_per_page;
968 /* Number of chars per line or UNIT_MAX is line folding is disabled.  */
969 static unsigned int chars_per_line;
970 /* Current count of lines printed on this page, chars on this line.  */
971 static unsigned int lines_printed, chars_printed;
972
973 /* Buffer and start column of buffered text, for doing smarter word-
974    wrapping.  When someone calls wrap_here(), we start buffering output
975    that comes through fputs_filtered().  If we see a newline, we just
976    spit it out and forget about the wrap_here().  If we see another
977    wrap_here(), we spit it out and remember the newer one.  If we see
978    the end of the line, we spit out a newline, the indent, and then
979    the buffered output.  */
980
981 /* Malloc'd buffer with chars_per_line+2 bytes.  Contains characters which
982    are waiting to be output (they have already been counted in chars_printed).
983    When wrap_buffer[0] is null, the buffer is empty.  */
984 static char *wrap_buffer;
985
986 /* Pointer in wrap_buffer to the next character to fill.  */
987 static char *wrap_pointer;
988
989 /* String to indent by if the wrap occurs.  Must not be NULL if wrap_column
990    is non-zero.  */
991 static char *wrap_indent;
992
993 /* Column number on the screen where wrap_buffer begins, or 0 if wrapping
994    is not in effect.  */
995 static int wrap_column;
996
997 /* ARGSUSED */
998 static void 
999 set_width_command (args, from_tty, c)
1000      char *args;
1001      int from_tty;
1002      struct cmd_list_element *c;
1003 {
1004   if (!wrap_buffer)
1005     {
1006       wrap_buffer = (char *) xmalloc (chars_per_line + 2);
1007       wrap_buffer[0] = '\0';
1008     }
1009   else
1010     wrap_buffer = (char *) xrealloc (wrap_buffer, chars_per_line + 2);
1011   wrap_pointer = wrap_buffer;   /* Start it at the beginning */
1012 }
1013
1014 /* Wait, so the user can read what's on the screen.  Prompt the user
1015    to continue by pressing RETURN.  */
1016
1017 static void
1018 prompt_for_continue ()
1019 {
1020   char *ignore;
1021
1022   /* We must do this *before* we call gdb_readline, else it will eventually
1023      call us -- thinking that we're trying to print beyond the end of the 
1024      screen.  */
1025   reinitialize_more_filter ();
1026
1027   immediate_quit++;
1028   /* On a real operating system, the user can quit with SIGINT.
1029      But not on GO32.
1030
1031      'q' is provided on all systems so users don't have to change habits
1032      from system to system, and because telling them what to do in
1033      the prompt is more user-friendly than expecting them to think of
1034      SIGINT.  */
1035   /* Call readline, not gdb_readline, because GO32 readline handles control-C
1036      whereas control-C to gdb_readline will cause the user to get dumped
1037      out to DOS.  */
1038   ignore =
1039     readline ("---Type <return> to continue, or q <return> to quit---");
1040   if (ignore)
1041     {
1042       char *p = ignore;
1043       while (*p == ' ' || *p == '\t')
1044         ++p;
1045       if (p[0] == 'q')
1046         request_quit (SIGINT);
1047       free (ignore);
1048     }
1049   immediate_quit--;
1050
1051   /* Now we have to do this again, so that GDB will know that it doesn't
1052      need to save the ---Type <return>--- line at the top of the screen.  */
1053   reinitialize_more_filter ();
1054
1055   dont_repeat ();               /* Forget prev cmd -- CR won't repeat it. */
1056 }
1057
1058 /* Reinitialize filter; ie. tell it to reset to original values.  */
1059
1060 void
1061 reinitialize_more_filter ()
1062 {
1063   lines_printed = 0;
1064   chars_printed = 0;
1065 }
1066
1067 /* Indicate that if the next sequence of characters overflows the line,
1068    a newline should be inserted here rather than when it hits the end. 
1069    If INDENT is non-null, it is a string to be printed to indent the
1070    wrapped part on the next line.  INDENT must remain accessible until
1071    the next call to wrap_here() or until a newline is printed through
1072    fputs_filtered().
1073
1074    If the line is already overfull, we immediately print a newline and
1075    the indentation, and disable further wrapping.
1076
1077    If we don't know the width of lines, but we know the page height,
1078    we must not wrap words, but should still keep track of newlines
1079    that were explicitly printed.
1080
1081    INDENT should not contain tabs, as that will mess up the char count
1082    on the next line.  FIXME.
1083
1084    This routine is guaranteed to force out any output which has been
1085    squirreled away in the wrap_buffer, so wrap_here ((char *)0) can be
1086    used to force out output from the wrap_buffer.  */
1087
1088 void
1089 wrap_here(indent)
1090      char *indent;
1091 {
1092   if (wrap_buffer[0])
1093     {
1094       *wrap_pointer = '\0';
1095       fputs  (wrap_buffer, gdb_stdout);
1096     }
1097   wrap_pointer = wrap_buffer;
1098   wrap_buffer[0] = '\0';
1099   if (chars_per_line == UINT_MAX)               /* No line overflow checking */
1100     {
1101       wrap_column = 0;
1102     }
1103   else if (chars_printed >= chars_per_line)
1104     {
1105       puts_filtered ("\n");
1106       if (indent != NULL)
1107         puts_filtered (indent);
1108       wrap_column = 0;
1109     }
1110   else
1111     {
1112       wrap_column = chars_printed;
1113       if (indent == NULL)
1114         wrap_indent = "";
1115       else
1116         wrap_indent = indent;
1117     }
1118 }
1119
1120 /* Ensure that whatever gets printed next, using the filtered output
1121    commands, starts at the beginning of the line.  I.E. if there is
1122    any pending output for the current line, flush it and start a new
1123    line.  Otherwise do nothing. */
1124
1125 void
1126 begin_line ()
1127 {
1128   if (chars_printed > 0)
1129     {
1130       puts_filtered ("\n");
1131     }
1132 }
1133
1134
1135 GDB_FILE *
1136 gdb_fopen (name, mode)
1137      char * name;
1138      char * mode;
1139 {
1140   return fopen (name, mode);
1141 }
1142
1143 void
1144 gdb_flush (stream)
1145      FILE *stream;
1146 {
1147   fflush (stream);
1148 }
1149
1150 /* Like fputs but if FILTER is true, pause after every screenful.
1151
1152    Regardless of FILTER can wrap at points other than the final
1153    character of a line.
1154
1155    Unlike fputs, fputs_maybe_filtered does not return a value.
1156    It is OK for LINEBUFFER to be NULL, in which case just don't print
1157    anything.
1158
1159    Note that a longjmp to top level may occur in this routine (only if
1160    FILTER is true) (since prompt_for_continue may do so) so this
1161    routine should not be called when cleanups are not in place.  */
1162
1163 static void
1164 fputs_maybe_filtered (linebuffer, stream, filter)
1165      const char *linebuffer;
1166      FILE *stream;
1167      int filter;
1168 {
1169   const char *lineptr;
1170
1171   if (linebuffer == 0)
1172     return;
1173   
1174   /* Don't do any filtering if it is disabled.  */
1175   if (stream != gdb_stdout
1176    || (lines_per_page == UINT_MAX && chars_per_line == UINT_MAX))
1177     {
1178       fputs (linebuffer, stream);
1179       return;
1180     }
1181
1182   /* Go through and output each character.  Show line extension
1183      when this is necessary; prompt user for new page when this is
1184      necessary.  */
1185   
1186   lineptr = linebuffer;
1187   while (*lineptr)
1188     {
1189       /* Possible new page.  */
1190       if (filter &&
1191           (lines_printed >= lines_per_page - 1))
1192         prompt_for_continue ();
1193
1194       while (*lineptr && *lineptr != '\n')
1195         {
1196           /* Print a single line.  */
1197           if (*lineptr == '\t')
1198             {
1199               if (wrap_column)
1200                 *wrap_pointer++ = '\t';
1201               else
1202                 putc ('\t', stream);
1203               /* Shifting right by 3 produces the number of tab stops
1204                  we have already passed, and then adding one and
1205                  shifting left 3 advances to the next tab stop.  */
1206               chars_printed = ((chars_printed >> 3) + 1) << 3;
1207               lineptr++;
1208             }
1209           else
1210             {
1211               if (wrap_column)
1212                 *wrap_pointer++ = *lineptr;
1213               else
1214                 putc (*lineptr, stream);
1215               chars_printed++;
1216               lineptr++;
1217             }
1218       
1219           if (chars_printed >= chars_per_line)
1220             {
1221               unsigned int save_chars = chars_printed;
1222
1223               chars_printed = 0;
1224               lines_printed++;
1225               /* If we aren't actually wrapping, don't output newline --
1226                  if chars_per_line is right, we probably just overflowed
1227                  anyway; if it's wrong, let us keep going.  */
1228               if (wrap_column)
1229                 putc ('\n', stream);
1230
1231               /* Possible new page.  */
1232               if (lines_printed >= lines_per_page - 1)
1233                 prompt_for_continue ();
1234
1235               /* Now output indentation and wrapped string */
1236               if (wrap_column)
1237                 {
1238                   fputs (wrap_indent, stream);
1239                   *wrap_pointer = '\0';         /* Null-terminate saved stuff */
1240                   fputs (wrap_buffer, stream);  /* and eject it */
1241                   /* FIXME, this strlen is what prevents wrap_indent from
1242                      containing tabs.  However, if we recurse to print it
1243                      and count its chars, we risk trouble if wrap_indent is
1244                      longer than (the user settable) chars_per_line. 
1245                      Note also that this can set chars_printed > chars_per_line
1246                      if we are printing a long string.  */
1247                   chars_printed = strlen (wrap_indent)
1248                                 + (save_chars - wrap_column);
1249                   wrap_pointer = wrap_buffer;   /* Reset buffer */
1250                   wrap_buffer[0] = '\0';
1251                   wrap_column = 0;              /* And disable fancy wrap */
1252                 }
1253             }
1254         }
1255
1256       if (*lineptr == '\n')
1257         {
1258           chars_printed = 0;
1259           wrap_here ((char *)0);  /* Spit out chars, cancel further wraps */
1260           lines_printed++;
1261           putc ('\n', stream);
1262           lineptr++;
1263         }
1264     }
1265 }
1266
1267 void
1268 fputs_filtered (linebuffer, stream)
1269      const char *linebuffer;
1270      FILE *stream;
1271 {
1272   fputs_maybe_filtered (linebuffer, stream, 1);
1273 }
1274
1275 void
1276 fputs_unfiltered (linebuffer, stream)
1277      const char *linebuffer;
1278      FILE *stream;
1279 {
1280 #if 0
1281
1282   /* This gets the wrap_buffer buffering wrong when called from
1283      gdb_readline (GDB was sometimes failing to print the prompt
1284      before reading input).  Even at other times, it seems kind of
1285      misguided, especially now that printf_unfiltered doesn't use
1286      printf_maybe_filtered.  */
1287
1288   fputs_maybe_filtered (linebuffer, stream, 0);
1289 #else
1290   fputs (linebuffer, stream);
1291 #endif
1292 }
1293
1294 void
1295 putc_unfiltered (c)
1296      int c;
1297 {
1298   char buf[2];
1299   buf[0] = c;
1300   buf[1] = 0;
1301   fputs_unfiltered (buf, gdb_stdout);
1302 }
1303
1304 void
1305 fputc_unfiltered (c, stream)
1306      int c;
1307      FILE * stream;
1308 {
1309   char buf[2];
1310   buf[0] = c;
1311   buf[1] = 0;
1312   fputs_unfiltered (buf, stream);
1313 }
1314
1315
1316 /* Print a variable number of ARGS using format FORMAT.  If this
1317    information is going to put the amount written (since the last call
1318    to REINITIALIZE_MORE_FILTER or the last page break) over the page size,
1319    print out a pause message and do a gdb_readline to get the users
1320    permision to continue.
1321
1322    Unlike fprintf, this function does not return a value.
1323
1324    We implement three variants, vfprintf (takes a vararg list and stream),
1325    fprintf (takes a stream to write on), and printf (the usual).
1326
1327    Note that this routine has a restriction that the length of the
1328    final output line must be less than 255 characters *or* it must be
1329    less than twice the size of the format string.  This is a very
1330    arbitrary restriction, but it is an internal restriction, so I'll
1331    put it in.  This means that the %s format specifier is almost
1332    useless; unless the caller can GUARANTEE that the string is short
1333    enough, fputs_filtered should be used instead.
1334
1335    Note also that a longjmp to top level may occur in this routine
1336    (since prompt_for_continue may do so) so this routine should not be
1337    called when cleanups are not in place.  */
1338
1339 #define MIN_LINEBUF     255
1340
1341 static void
1342 vfprintf_maybe_filtered (stream, format, args, filter)
1343      FILE *stream;
1344      char *format;
1345      va_list args;
1346      int filter;
1347 {
1348   char line_buf[MIN_LINEBUF+10];
1349   char *linebuffer = line_buf;
1350   int format_length;
1351
1352   format_length = strlen (format);
1353
1354   /* Reallocate buffer to a larger size if this is necessary.  */
1355   if (format_length * 2 > MIN_LINEBUF)
1356     {
1357       linebuffer = alloca (10 + format_length * 2);
1358     }
1359
1360   /* This won't blow up if the restrictions described above are
1361      followed.   */
1362   vsprintf (linebuffer, format, args);
1363
1364   fputs_maybe_filtered (linebuffer, stream, filter);
1365 }
1366
1367
1368 void
1369 vfprintf_filtered (stream, format, args)
1370      FILE *stream;
1371      char *format;
1372      va_list args;
1373 {
1374   vfprintf_maybe_filtered (stream, format, args, 1);
1375 }
1376
1377 void
1378 vfprintf_unfiltered (stream, format, args)
1379      FILE *stream;
1380      char *format;
1381      va_list args;
1382 {
1383   vfprintf (stream, format, args);
1384 }
1385
1386 void
1387 vprintf_filtered (format, args)
1388      char *format;
1389      va_list args;
1390 {
1391   vfprintf_maybe_filtered (gdb_stdout, format, args, 1);
1392 }
1393
1394 void
1395 vprintf_unfiltered (format, args)
1396      char *format;
1397      va_list args;
1398 {
1399   vfprintf (gdb_stdout, format, args);
1400 }
1401
1402 /* VARARGS */
1403 void
1404 fprintf_filtered (va_alist)
1405      va_dcl
1406 {
1407   va_list args;
1408   FILE *stream;
1409   char *format;
1410
1411   va_start (args);
1412   stream = va_arg (args, FILE *);
1413   format = va_arg (args, char *);
1414
1415   /* This won't blow up if the restrictions described above are
1416      followed.   */
1417   vfprintf_filtered (stream, format, args);
1418   va_end (args);
1419 }
1420
1421 /* VARARGS */
1422 void
1423 fprintf_unfiltered (va_alist)
1424      va_dcl
1425 {
1426   va_list args;
1427   FILE *stream;
1428   char *format;
1429
1430   va_start (args);
1431   stream = va_arg (args, FILE *);
1432   format = va_arg (args, char *);
1433
1434   /* This won't blow up if the restrictions described above are
1435      followed.   */
1436   vfprintf_unfiltered (stream, format, args);
1437   va_end (args);
1438 }
1439
1440 /* Like fprintf_filtered, but prints it's result indent.
1441    Called as fprintfi_filtered (spaces, stream, format, ...);  */
1442
1443 /* VARARGS */
1444 void
1445 fprintfi_filtered (va_alist)
1446      va_dcl
1447 {
1448   va_list args;
1449   int spaces;
1450   FILE *stream;
1451   char *format;
1452
1453   va_start (args);
1454   spaces = va_arg (args, int);
1455   stream = va_arg (args, FILE *);
1456   format = va_arg (args, char *);
1457   print_spaces_filtered (spaces, stream);
1458
1459   /* This won't blow up if the restrictions described above are
1460      followed.   */
1461   vfprintf_filtered (stream, format, args);
1462   va_end (args);
1463 }
1464
1465
1466 /* VARARGS */
1467 void
1468 printf_filtered (va_alist)
1469      va_dcl
1470 {
1471   va_list args;
1472   char *format;
1473
1474   va_start (args);
1475   format = va_arg (args, char *);
1476
1477   vfprintf_filtered (gdb_stdout, format, args);
1478   va_end (args);
1479 }
1480
1481
1482 /* VARARGS */
1483 void
1484 printf_unfiltered (va_alist)
1485      va_dcl
1486 {
1487   va_list args;
1488   char *format;
1489
1490   va_start (args);
1491   format = va_arg (args, char *);
1492
1493   vfprintf_unfiltered (gdb_stdout, format, args);
1494   va_end (args);
1495 }
1496
1497 /* Like printf_filtered, but prints it's result indented.
1498    Called as printfi_filtered (spaces, format, ...);  */
1499
1500 /* VARARGS */
1501 void
1502 printfi_filtered (va_alist)
1503      va_dcl
1504 {
1505   va_list args;
1506   int spaces;
1507   char *format;
1508
1509   va_start (args);
1510   spaces = va_arg (args, int);
1511   format = va_arg (args, char *);
1512   print_spaces_filtered (spaces, gdb_stdout);
1513   vfprintf_filtered (gdb_stdout, format, args);
1514   va_end (args);
1515 }
1516
1517 /* Easy -- but watch out!
1518
1519    This routine is *not* a replacement for puts()!  puts() appends a newline.
1520    This one doesn't, and had better not!  */
1521
1522 void
1523 puts_filtered (string)
1524      char *string;
1525 {
1526   fputs_filtered (string, gdb_stdout);
1527 }
1528
1529 void
1530 puts_unfiltered (string)
1531      char *string;
1532 {
1533   fputs_unfiltered (string, gdb_stdout);
1534 }
1535
1536 /* Return a pointer to N spaces and a null.  The pointer is good
1537    until the next call to here.  */
1538 char *
1539 n_spaces (n)
1540      int n;
1541 {
1542   register char *t;
1543   static char *spaces;
1544   static int max_spaces;
1545
1546   if (n > max_spaces)
1547     {
1548       if (spaces)
1549         free (spaces);
1550       spaces = (char *) xmalloc (n+1);
1551       for (t = spaces+n; t != spaces;)
1552         *--t = ' ';
1553       spaces[n] = '\0';
1554       max_spaces = n;
1555     }
1556
1557   return spaces + max_spaces - n;
1558 }
1559
1560 /* Print N spaces.  */
1561 void
1562 print_spaces_filtered (n, stream)
1563      int n;
1564      FILE *stream;
1565 {
1566   fputs_filtered (n_spaces (n), stream);
1567 }
1568 \f
1569 /* C++ demangler stuff.  */
1570
1571 /* fprintf_symbol_filtered attempts to demangle NAME, a symbol in language
1572    LANG, using demangling args ARG_MODE, and print it filtered to STREAM.
1573    If the name is not mangled, or the language for the name is unknown, or
1574    demangling is off, the name is printed in its "raw" form. */
1575
1576 void
1577 fprintf_symbol_filtered (stream, name, lang, arg_mode)
1578      FILE *stream;
1579      char *name;
1580      enum language lang;
1581      int arg_mode;
1582 {
1583   char *demangled;
1584
1585   if (name != NULL)
1586     {
1587       /* If user wants to see raw output, no problem.  */
1588       if (!demangle)
1589         {
1590           fputs_filtered (name, stream);
1591         }
1592       else
1593         {
1594           switch (lang)
1595             {
1596             case language_cplus:
1597               demangled = cplus_demangle (name, arg_mode);
1598               break;
1599             case language_chill:
1600               demangled = chill_demangle (name);
1601               break;
1602             default:
1603               demangled = NULL;
1604               break;
1605             }
1606           fputs_filtered (demangled ? demangled : name, stream);
1607           if (demangled != NULL)
1608             {
1609               free (demangled);
1610             }
1611         }
1612     }
1613 }
1614
1615 /* Do a strcmp() type operation on STRING1 and STRING2, ignoring any
1616    differences in whitespace.  Returns 0 if they match, non-zero if they
1617    don't (slightly different than strcmp()'s range of return values).
1618    
1619    As an extra hack, string1=="FOO(ARGS)" matches string2=="FOO".
1620    This "feature" is useful when searching for matching C++ function names
1621    (such as if the user types 'break FOO', where FOO is a mangled C++
1622    function). */
1623
1624 int
1625 strcmp_iw (string1, string2)
1626      const char *string1;
1627      const char *string2;
1628 {
1629   while ((*string1 != '\0') && (*string2 != '\0'))
1630     {
1631       while (isspace (*string1))
1632         {
1633           string1++;
1634         }
1635       while (isspace (*string2))
1636         {
1637           string2++;
1638         }
1639       if (*string1 != *string2)
1640         {
1641           break;
1642         }
1643       if (*string1 != '\0')
1644         {
1645           string1++;
1646           string2++;
1647         }
1648     }
1649   return (*string1 != '\0' && *string1 != '(') || (*string2 != '\0');
1650 }
1651
1652 \f
1653 void
1654 _initialize_utils ()
1655 {
1656   struct cmd_list_element *c;
1657
1658   c = add_set_cmd ("width", class_support, var_uinteger, 
1659                   (char *)&chars_per_line,
1660                   "Set number of characters gdb thinks are in a line.",
1661                   &setlist);
1662   add_show_from_set (c, &showlist);
1663   c->function.sfunc = set_width_command;
1664
1665   add_show_from_set
1666     (add_set_cmd ("height", class_support,
1667                   var_uinteger, (char *)&lines_per_page,
1668                   "Set number of lines gdb thinks are in a page.", &setlist),
1669      &showlist);
1670   
1671   /* These defaults will be used if we are unable to get the correct
1672      values from termcap.  */
1673 #if defined(__GO32__)
1674   lines_per_page = ScreenRows();
1675   chars_per_line = ScreenCols();
1676 #else  
1677   lines_per_page = 24;
1678   chars_per_line = 80;
1679   /* Initialize the screen height and width from termcap.  */
1680   {
1681     char *termtype = getenv ("TERM");
1682
1683     /* Positive means success, nonpositive means failure.  */
1684     int status;
1685
1686     /* 2048 is large enough for all known terminals, according to the
1687        GNU termcap manual.  */
1688     char term_buffer[2048];
1689
1690     if (termtype)
1691       {
1692         status = tgetent (term_buffer, termtype);
1693         if (status > 0)
1694           {
1695             int val;
1696             
1697             val = tgetnum ("li");
1698             if (val >= 0)
1699               lines_per_page = val;
1700             else
1701               /* The number of lines per page is not mentioned
1702                  in the terminal description.  This probably means
1703                  that paging is not useful (e.g. emacs shell window),
1704                  so disable paging.  */
1705               lines_per_page = UINT_MAX;
1706             
1707             val = tgetnum ("co");
1708             if (val >= 0)
1709               chars_per_line = val;
1710           }
1711       }
1712   }
1713
1714 #if defined(SIGWINCH) && defined(SIGWINCH_HANDLER)
1715
1716   /* If there is a better way to determine the window size, use it. */
1717   SIGWINCH_HANDLER ();
1718 #endif
1719 #endif
1720   /* If the output is not a terminal, don't paginate it.  */
1721   if (!ISATTY (gdb_stdout))
1722     lines_per_page = UINT_MAX;
1723
1724   set_width_command ((char *)NULL, 0, c);
1725
1726   add_show_from_set
1727     (add_set_cmd ("demangle", class_support, var_boolean, 
1728                   (char *)&demangle,
1729                 "Set demangling of encoded C++ names when displaying symbols.",
1730                   &setprintlist),
1731      &showprintlist);
1732
1733   add_show_from_set
1734     (add_set_cmd ("sevenbit-strings", class_support, var_boolean, 
1735                   (char *)&sevenbit_strings,
1736    "Set printing of 8-bit characters in strings as \\nnn.",
1737                   &setprintlist),
1738      &showprintlist);
1739
1740   add_show_from_set
1741     (add_set_cmd ("asm-demangle", class_support, var_boolean, 
1742                   (char *)&asm_demangle,
1743         "Set demangling of C++ names in disassembly listings.",
1744                   &setprintlist),
1745      &showprintlist);
1746 }
1747
1748 /* Machine specific function to handle SIGWINCH signal. */
1749
1750 #ifdef  SIGWINCH_HANDLER_BODY
1751         SIGWINCH_HANDLER_BODY
1752 #endif
1753
This page took 0.115605 seconds and 4 git commands to generate.