home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gdb-4.9 / gdb / utils.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-12  |  35.8 KB  |  1,521 lines

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