home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / gdb / gdb_18s.zoo / printcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-25  |  37.7 KB  |  1,528 lines

  1. /* Print values for GNU debugger GDB.
  2.    Copyright (C) 1986, 1987, 1988 Free Software Foundation, Inc.
  3.  
  4. GDB is distributed in the hope that it will be useful, but WITHOUT ANY
  5. WARRANTY.  No author or distributor accepts responsibility to anyone
  6. for the consequences of using it or for whether it serves any
  7. particular purpose or works at all, unless he says so in writing.
  8. Refer to the GDB General Public License for full details.
  9.  
  10. Everyone is granted permission to copy, modify and redistribute GDB,
  11. but only under the conditions described in the GDB General Public
  12. License.  A copy of this license is supposed to have been given to you
  13. along with GDB so you can know your rights and responsibilities.  It
  14. should be in a file named COPYING.  Among other things, the copyright
  15. notice and this notice must be preserved on all copies.
  16.  
  17. In other words, go ahead and share GDB, but don't try to stop
  18. anyone else from sharing it farther.  Help stamp out software hoarding!
  19. */
  20.  
  21. #include <stdio.h>
  22. #include "defs.h"
  23. #include "param.h"
  24. #include "frame.h"
  25. #include "symtab.h"
  26. #include "value.h"
  27. #include "expression.h"
  28.  
  29. struct format_data
  30. {
  31.   int count;
  32.   char format;
  33.   char size;
  34. };
  35.  
  36. /* Last specified output format.  */
  37.  
  38. static char last_format = 'x';
  39.  
  40. /* Last specified examination size.  'b', 'h', 'w' or `q'.  */
  41.  
  42. static char last_size = 'w';
  43.  
  44. /* Default address to examine next.  */
  45.  
  46. static CORE_ADDR next_address;
  47.  
  48. /* Last address examined.  */
  49.  
  50. static CORE_ADDR last_examine_address;
  51.  
  52. /* Contents of last address examined.
  53.    This is not valid past the end of the `x' command!  */
  54.  
  55. static value last_examine_value;
  56.  
  57. /* Number of auto-display expression currently being displayed.
  58.    So that we can deleted it if we get an error or a signal within it.
  59.    -1 when not doing one.  */
  60.  
  61. int current_display_number;
  62.  
  63. #ifdef atarist
  64. extern int gcc_mshort;
  65. #endif
  66. static void do_one_display ();
  67.  
  68. void do_displays ();
  69. void print_address ();
  70. void print_scalar_formatted ();
  71.  
  72.  
  73. /* Decode a format specification.  *STRING_PTR should point to it.
  74.    OFORMAT and OSIZE are used as defaults for the format and size
  75.    if none are given in the format specification.
  76.    If OSIZE is zero, then the size field of the returned value
  77.    should be set only if a size is explicitly specified by the
  78.    user.
  79.    The structure returned describes all the data
  80.    found in the specification.  In addition, *STRING_PTR is advanced
  81.    past the specification and past all whitespace following it.  */
  82.  
  83. struct format_data
  84. decode_format (string_ptr, oformat, osize)
  85.      char **string_ptr;
  86.      char oformat;
  87.      char osize;
  88. {
  89.   struct format_data val;
  90.   register char *p = *string_ptr;
  91.  
  92.   val.format = '?';
  93.   val.size = '?';
  94.   val.count = 1;
  95.  
  96.   if (*p >= '0' && *p <= '9')
  97.     val.count = atoi (p);
  98.   while (*p >= '0' && *p <= '9') p++;
  99.        
  100.   /* Now process size or format letters that follow.  */
  101.  
  102.   while (1)
  103.     {
  104.       if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
  105.     val.size = *p++;
  106.       else if (*p >= 'a' && *p <= 'z')
  107.     val.format = *p++;
  108.       else
  109.     break;
  110.     }
  111.  
  112.   /* Make sure 'g' size is not used on integer types.
  113.      Well, actually, we can handle hex.  */
  114.   if (val.size == 'g' && val.format != 'f' && val.format != 'x')
  115.     val.size = 'w';
  116.  
  117.   while (*p == ' ' || *p == '\t') p++;
  118.   *string_ptr = p;
  119.  
  120.   /* Set defaults for format and size if not specified.  */
  121.   if (val.format == '?')
  122.     {
  123.       if (val.size == '?')
  124.     {
  125.       /* Neither has been specified.  */
  126.       val.format = oformat;
  127.       val.size = osize;
  128.     }
  129.       else
  130.     /* If a size is specified, any format makes a reasonable
  131.        default except 'i'.  */
  132.     val.format = oformat == 'i' ? 'x' : oformat;
  133.     }
  134.   else if (val.size == '?')
  135.     switch (val.format)
  136.       {
  137.       case 'a':
  138.       case 's':
  139.     /* Addresses must be words.  */
  140.     val.size = osize ? 'w' : osize;
  141.     break;
  142.       case 'f':
  143.     /* Floating point has to be word or giantword.  */
  144.     if (osize == 'w' || osize == 'g')
  145.       val.size = osize;
  146.     else
  147.       /* Default it to giantword if the last used size is not
  148.          appropriate.  */
  149.       val.size = osize ? 'g' : osize;
  150.     break;
  151.       case 'c':
  152.     /* Characters default to one byte.  */
  153.     val.size = osize ? 'b' : osize;
  154.     break;
  155.       default:
  156.     /* The default is the size most recently specified.  */
  157.     val.size = osize;
  158.       }
  159.  
  160.   return val;
  161. }
  162.  
  163. /* Print value VAL on stdout according to FORMAT, a letter or 0.
  164.    Do not end with a newline.
  165.    0 means print VAL according to its own type.
  166.    SIZE is the letter for the size of datum being printed.
  167.    This is used to pad hex numbers so they line up.  */
  168.  
  169. static void
  170. print_formatted (val, format, size)
  171.      register value val;
  172.      register char format;
  173.      char size;
  174. {
  175.   int len = TYPE_LENGTH (VALUE_TYPE (val));
  176.  
  177.   if (VALUE_LVAL (val) == lval_memory)
  178.     next_address = VALUE_ADDRESS (val) + len;
  179.  
  180.   switch (format)
  181.     {
  182.     case 's':
  183.       next_address = VALUE_ADDRESS (val)
  184.     + value_print (value_addr (val), stdout, 0);
  185.       break;
  186.  
  187.     case 'i':
  188.       next_address = VALUE_ADDRESS (val)
  189.     + print_insn (VALUE_ADDRESS (val), stdout);
  190.       break;
  191.  
  192.     default:
  193.       if (format == 0
  194.       || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_ARRAY
  195.       || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_STRUCT
  196.       || TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_UNION)
  197.     value_print (val, stdout, format);
  198.       else
  199.     print_scalar_formatted (VALUE_CONTENTS (val), VALUE_TYPE (val),
  200.                 format, size, stdout);
  201.     }
  202. }
  203.  
  204. /* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
  205.    according to letters FORMAT and SIZE on STREAM.
  206.    FORMAT may not be zero.  Formats s and i are not supported at this level.
  207.  
  208.    This is how the elements of an array or structure are printed
  209.    with a format.  */
  210.  
  211. void
  212. print_scalar_formatted (valaddr, type, format, size, stream)
  213.      char *valaddr;
  214.      struct type *type;
  215.      char format;
  216.      int size;
  217.      FILE *stream;
  218. {
  219.   long val_long;
  220.   int len = TYPE_LENGTH (type);
  221.  
  222.   if (size == 'g' && sizeof (long) < 8
  223.       && format == 'x')
  224.     {
  225.       /* ok, we're going to have to get fancy here.  Assumption: a
  226.          long is four bytes.  FIXME.  */
  227.       unsigned long v1, v2, tmp;
  228.  
  229.       v1 = unpack_long (builtin_type_long, valaddr);
  230.       v2 = unpack_long (builtin_type_long, valaddr + 4);
  231.  
  232.       switch (format)
  233.     {
  234.     case 'x':
  235.       fprintf_filtered (stream, "0x%08x%08x", v1, v2);
  236.       break;
  237.     default:
  238.       error ("Output size \"g\" unimplemented for format \"%c\".",
  239.          format);
  240.     }
  241.       return;
  242.     }
  243.       
  244.   val_long = unpack_long (type, valaddr);
  245.  
  246.   /* If value is unsigned, truncate it in case negative.  */
  247.   if (format != 'd')
  248.     {
  249.       if (len == sizeof (char))
  250.     val_long &= (1 << 8 * sizeof(char)) - 1;
  251.       else if (len == sizeof (short))
  252.     val_long &= (1 << 8 * sizeof(short)) - 1;
  253.       else if (len == sizeof (long))
  254.     val_long &= (unsigned long) - 1;
  255.     }
  256.  
  257.   switch (format)
  258.     {
  259.     case 'x':
  260.       if (!size)
  261.     {
  262.       /* no size specified, like in print.  Print varying # of digits. */
  263.       fprintf_filtered (stream, "0x%lx", val_long);
  264.     }
  265.       else
  266.       switch (size)
  267.     {
  268.     case 'b':
  269.       fprintf_filtered (stream, "0x%02x", val_long);
  270.       break;
  271.     case 'h':
  272.       fprintf_filtered (stream, "0x%04x", val_long);
  273.       break;
  274.     case 'w':
  275.       fprintf_filtered (stream, "0x%08x", val_long);
  276.       break;
  277.     case 'g':
  278.       fprintf_filtered (stream, "0x%016x", val_long);
  279.       break;
  280.     default:
  281.       error ("Undefined output size \"%c\".", size);
  282.     }
  283.       break;
  284.  
  285.     case 'd':
  286.       fprintf_filtered (stream, "%d", val_long);
  287.       break;
  288.  
  289.     case 'u':
  290.       fprintf_filtered (stream, "%u", val_long);
  291.       break;
  292.  
  293.     case 'o':
  294.       if (val_long)
  295.     fprintf_filtered (stream, "0%o", val_long);
  296.       else
  297.     fprintf_filtered (stream, "0");
  298.       break;
  299.  
  300.     case 'a':
  301.       print_address (val_long, stream);
  302.       break;
  303.  
  304.     case 'c':
  305.       value_print (value_from_long (builtin_type_char, val_long), stream, 0);
  306.       break;
  307.  
  308.     case 'f':
  309.       if (len == sizeof (float))
  310.     type = builtin_type_float;
  311.       if (len == sizeof (double))
  312.     type = builtin_type_double;
  313. #ifdef IEEE_FLOAT
  314.       if (is_nan (unpack_double (type, valaddr)))
  315.     {
  316.      printf_filtered ("Nan");
  317.       break;
  318.     }
  319. #endif
  320.       fprintf_filtered (stream, "%g", unpack_double (type, valaddr));
  321.       break;
  322.  
  323.     case 0:
  324.       abort ();
  325.  
  326.       /* Binary; 't' stands for "two".  */
  327.       {
  328.         char bits[8*(sizeof val_long) + 1];
  329.     char *cp = bits;
  330.     int width;
  331.  
  332.         if (!size)
  333.       width = 8*(sizeof val_long);
  334.         else
  335.           switch (size)
  336.         {
  337.         case 'b':
  338.           width = 8;
  339.           break;
  340.         case 'h':
  341.           width = 16;
  342.           break;
  343.         case 'w':
  344.           width = 32;
  345.           break;
  346.         case 'g':
  347.           width = 64;
  348.           break;
  349.         default:
  350.           error ("Undefined output size \"%c\".", size);
  351.         }
  352.  
  353.         bits[width] = '\0';
  354.         while (width-- > 0)
  355.           {
  356.             bits[width] = (val_long & 1) ? '1' : '0';
  357.             val_long >>= 1;
  358.           }
  359.     if (!size)
  360.       {
  361.         while (*cp && *cp == '0')
  362.           cp++;
  363.         if (*cp == '\0')
  364.           cp--;
  365.       }
  366.         fprintf_filtered (stream, cp);
  367.       }
  368.       break;
  369.  
  370.     default:
  371.       error ("Undefined output format \"%c\".", format);
  372.     }
  373. }
  374.  
  375. /* Specify default address for `x' command.
  376.    `info lines' uses this.  */
  377.  
  378. void
  379. set_next_address (addr)
  380.      CORE_ADDR addr;
  381. {
  382.   next_address = addr;
  383.  
  384.   /* Make address available to the user as $_.  */
  385.   set_internalvar (lookup_internalvar ("_"),
  386.            value_from_long (builtin_type_int, addr));
  387. }
  388.  
  389. void
  390. print_address_symbolic (addr, stream, do_demangle, leadin)
  391.      CORE_ADDR addr;
  392.      FILE *stream;
  393.      int do_demangle;
  394.      char *leadin;
  395. {
  396.   int name_location;
  397.   register int i = find_pc_misc_function (addr);
  398.  
  399.   /* If nothing comes out, don't print anything symbolic.  */
  400.   
  401.   if (i < 0)
  402.     return;
  403.  
  404.   fputs_filtered (leadin, stream);
  405.   fputs_filtered ("<", stream);
  406. #if 0
  407.   if (do_demangle)
  408.     fputs_filtered_demangled (misc_function_vector[i].name, stream, 1);
  409.   else
  410. #endif
  411.     fputs_filtered (misc_function_vector[i].name, stream);
  412.   name_location = misc_function_vector[i].address;
  413.   if (addr - name_location)
  414.     fprintf_filtered (stream, "+%d>", addr - name_location);
  415.   else
  416.     fputs_filtered (">", stream);
  417. }
  418.  
  419. /* Print address ADDR symbolically on STREAM.
  420.    First print it as a number.  Then perhaps print
  421.    <SYMBOL + OFFSET> after the number.  */
  422.  
  423. void
  424. print_address (addr, stream)
  425.      CORE_ADDR addr;
  426.      FILE *stream;
  427. {
  428.   fprintf_filtered (stream, "0x%x", addr);
  429. #if 0
  430.   print_address_symbolic (addr, stream, asm_demangle, " ");
  431. #else
  432.   print_address_symbolic (addr, stream, 0, " ");
  433. #endif
  434. }
  435.  
  436. /* Examine data at address ADDR in format FMT.
  437.    Fetch it from memory and print on stdout.  */
  438.  
  439. static void
  440. do_examine (fmt, addr)
  441.      struct format_data fmt;
  442.      CORE_ADDR addr;
  443. {
  444.   register char format = 0;
  445.   register char size;
  446.   register int count = 1;
  447.   struct type *val_type;
  448.   register int i;
  449.   register int maxelts;
  450.  
  451.   format = fmt.format;
  452.   size = fmt.size;
  453.   count = fmt.count;
  454.   next_address = addr;
  455.  
  456.   /* String or instruction format implies fetch single bytes
  457.      regardless of the specified size.  */
  458.   if (format == 's' || format == 'i')
  459.     size = 'b';
  460.  
  461.   if (size == 'b')
  462.     val_type = builtin_type_char;
  463.   else if (size == 'h')
  464.     val_type = builtin_type_short;
  465.   else if (size == 'w')
  466.     val_type = builtin_type_long;
  467.   else if (size == 'g')
  468.     val_type = builtin_type_double;
  469.  
  470.   maxelts = 8;
  471.   if (size == 'w')
  472.     maxelts = 4;
  473.   if (size == 'g')
  474.     maxelts = 2;
  475.   if (format == 's' || format == 'i')
  476.     maxelts = 1;
  477.  
  478.   /* Print as many objects as specified in COUNT, at most maxelts per line,
  479.      with the address of the next one at the start of each line.  */
  480.  
  481.   while (count > 0)
  482.     {
  483.       print_address (next_address, stdout);
  484.       fputc_filtered (':', stdout);
  485.       for (i = maxelts;
  486.        i > 0 && count > 0;
  487.        i--, count--)
  488.     {
  489.       fputc_filtered ('\t', stdout);
  490.       /* Note that this sets next_address for the next object.  */
  491.       last_examine_address = next_address;
  492.       last_examine_value = value_at (val_type, next_address);
  493.       print_formatted (last_examine_value, format, size);
  494.     }
  495.       fputc_filtered ('\n', stdout);
  496.       fflush (stdout);
  497.     }
  498. }
  499.  
  500. static void
  501. validate_format (fmt, cmdname)
  502.      struct format_data fmt;
  503.      char *cmdname;
  504. {
  505.   if (fmt.size != 0)
  506.     error ("Size letters are meaningless in \"%s\" command.", cmdname);
  507.   if (fmt.count != 1)
  508.     error ("Item count other than 1 is meaningless in \"%s\" command.",
  509.        cmdname);
  510.   if (fmt.format == 'i' || fmt.format == 's')
  511.     error ("Format letter \"%c\" is meaningless in \"%s\" command.",
  512.        fmt.format, cmdname);
  513. }
  514.  
  515. static void
  516. print_command (exp)
  517.      char *exp;
  518. {
  519.   struct expression *expr;
  520.   register struct cleanup *old_chain = 0;
  521.   register char format = 0;
  522.   register value val;
  523.   struct format_data fmt;
  524.   int histindex;
  525.   int cleanup = 0;
  526.  
  527.   if (exp && *exp == '/')
  528.     {
  529.       exp++;
  530.       fmt = decode_format (&exp, last_format, 0);
  531.       validate_format (fmt, "print");
  532.       last_format = format = fmt.format;
  533.     }
  534.   else
  535.     {
  536.       fmt.count = 1;
  537.       fmt.format = 0;
  538.       fmt.size = 0;
  539.     }
  540.  
  541.   if (exp && *exp)
  542.     {
  543.       expr = parse_c_expression (exp);
  544.       old_chain = make_cleanup (free_current_contents, &expr);
  545.       cleanup = 1;
  546.       val = evaluate_expression (expr);
  547.     }
  548.   else
  549.     val = access_value_history (0);
  550.  
  551.   histindex = record_latest_value (val);
  552.   if(histindex >= 0)printf_filtered ("$%d = ", histindex);
  553.  
  554.   print_formatted (val, format, fmt.size);
  555.  printf_filtered ("\n");
  556.  
  557.   if (cleanup)
  558.     do_cleanups (old_chain);
  559. }
  560.  
  561. static void
  562. output_command (exp)
  563.      char *exp;
  564. {
  565.   struct expression *expr;
  566.   register struct cleanup *old_chain;
  567.   register char format = 0;
  568.   register value val;
  569.   struct format_data fmt;
  570.  
  571.   if (exp && *exp == '/')
  572.     {
  573.       exp++;
  574.       fmt = decode_format (&exp, 0, 0);
  575.       validate_format (fmt, "print");
  576.       format = fmt.format;
  577.     }
  578.  
  579.   expr = parse_c_expression (exp);
  580.   old_chain = make_cleanup (free_current_contents, &expr);
  581.  
  582.   val = evaluate_expression (expr);
  583.  
  584.   print_formatted (val, format, fmt.size);
  585.  
  586.   do_cleanups (old_chain);
  587. }
  588.  
  589. static void
  590. set_command (exp)
  591.      char *exp;
  592. {
  593.   struct expression *expr = parse_c_expression (exp);
  594.   register struct cleanup *old_chain
  595.     = make_cleanup (free_current_contents, &expr);
  596.   evaluate_expression (expr);
  597.   do_cleanups (old_chain);
  598. }
  599.  
  600. static void
  601. address_info (exp)
  602.      char *exp;
  603. {
  604.   register struct symbol *sym;
  605.   register CORE_ADDR val;
  606.  
  607.   if (exp == 0)
  608.     error ("Argument required.");
  609.  
  610.   sym = lookup_symbol (exp, get_selected_block (), VAR_NAMESPACE);
  611.   if (sym == 0)
  612.     {
  613.       register int i;
  614.  
  615.       for (i = 0; i < misc_function_count; i++)
  616.     if (!strcmp (misc_function_vector[i].name, exp))
  617.       break;
  618.  
  619.       if (i < misc_function_count)
  620. printf_filtered ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n",
  621.         exp, misc_function_vector[i].address);
  622.       else
  623.     error ("No symbol \"%s\" in current context.", exp);
  624.       return;
  625.     }
  626.  
  627.  printf_filtered ("Symbol \"%s\" is ", SYMBOL_NAME (sym));
  628.   val = SYMBOL_VALUE (sym);
  629.  
  630.   switch (SYMBOL_CLASS (sym))
  631.     {
  632.     case LOC_CONST:
  633.     case LOC_CONST_BYTES:
  634.      printf_filtered ("constant");
  635.       break;
  636.  
  637.     case LOC_LABEL:
  638.      printf_filtered ("a label at address 0x%x", val);
  639.       break;
  640.  
  641.     case LOC_REGISTER:
  642.      printf_filtered ("a variable in register %s", reg_names[val]);
  643.       break;
  644.  
  645.     case LOC_STATIC:
  646.      printf_filtered ("static at address 0x%x", val);
  647.       break;
  648.  
  649.     case LOC_ARG:
  650.      printf_filtered ("an argument at offset %d", val);
  651.       break;
  652.  
  653.     case LOC_LOCAL:
  654.      printf_filtered ("a local variable at frame offset %d", val);
  655.       break;
  656.  
  657.     case LOC_TYPEDEF:
  658.      printf_filtered ("a typedef");
  659.       break;
  660.  
  661.     case LOC_BLOCK:
  662.      printf_filtered ("a function at address 0x%x",
  663.           BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
  664.       break;
  665.  
  666.     default:
  667.      printf_filtered ("of unknown (botched) type");
  668.       break;
  669.     }
  670.  printf_filtered (".\n");
  671. }
  672.  
  673. static void
  674. x_command (exp, from_tty)
  675.      char *exp;
  676.      int from_tty;
  677. {
  678.   struct expression *expr;
  679.   struct format_data fmt;
  680.   struct value *val;
  681.   struct cleanup *old_chain;
  682.  
  683.   fmt.format = last_format;
  684.   fmt.size = last_size;
  685.   fmt.count = 1;
  686.  
  687.   if (exp && *exp == '/')
  688.     {
  689.       exp++;
  690.       fmt = decode_format (&exp, last_format, last_size);
  691.       last_size = fmt.size;
  692.       last_format = fmt.format;
  693.     }
  694.  
  695.   /* If we have an expression, evaluate it and use it as the address.  */
  696.  
  697.   if (exp != 0 && *exp != 0)
  698.     {
  699.       expr = parse_c_expression (exp);
  700.       /* Cause expression not to be there any more
  701.      if this command is repeated with Newline.
  702.      But don't clobber a user-defined command's definition.  */
  703.       if (from_tty)
  704.     *exp = 0;
  705.       old_chain = make_cleanup (free_current_contents, &expr);
  706.       val = evaluate_expression (expr);
  707. #if 0
  708.       if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_REF)
  709.     val = value_ind (val);
  710. #endif
  711.       /* In rvalue contexts, such as this, functions are coerced into
  712.      pointers to functions.  This makes "x/i main" work.  */
  713.       if (/* last_format == 'i'
  714.       && */ TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_FUNC
  715.       && VALUE_LVAL (val) == lval_memory)
  716.     next_address = VALUE_ADDRESS (val);
  717.       else
  718.     next_address = value_as_long (val);
  719.       do_cleanups (old_chain);
  720.     }
  721.  
  722.   do_examine (fmt, next_address);
  723.  
  724.   /* Set a couple of internal variables if appropriate. */
  725.   if (last_examine_value)
  726.     {
  727.       /* Make last address examined available to the user as $_.  */
  728.       set_internalvar (lookup_internalvar ("_"),
  729.                value_from_long (builtin_type_int, 
  730.                     (long) last_examine_address));
  731.       
  732.       /* Make contents of last address examined available to the user as $__.*/
  733.       set_internalvar (lookup_internalvar ("__"), last_examine_value);
  734.     }
  735. }
  736.  
  737. /* Commands for printing types of things.  */
  738.  
  739. static void
  740. whatis_command (exp)
  741.      char *exp;
  742. {
  743.   struct expression *expr;
  744.   register value val;
  745.   register struct cleanup *old_chain;
  746.  
  747.   if (exp)
  748.     {
  749.       expr = parse_c_expression (exp);
  750.       old_chain = make_cleanup (free_current_contents, &expr);
  751.       val = evaluate_type (expr);
  752.     }
  753.   else
  754.     val = access_value_history (0);
  755.  
  756.  printf_filtered ("type = ");
  757.   type_print (VALUE_TYPE (val), "", stdout, 1);
  758.  printf_filtered ("\n");
  759.  
  760.   if (exp)
  761.     do_cleanups (old_chain);
  762. }
  763.  
  764. static void
  765. ptype_command (typename)
  766.      char *typename;
  767. {
  768.   register char *p = typename;
  769.   register int len;
  770.   extern struct block *get_current_block ();
  771.   register struct block *b
  772.     = (have_inferior_p () || have_core_file_p ()) ? get_current_block () : 0;
  773.   register struct type *type;
  774.  
  775.   if (typename == 0)
  776.     error_no_arg ("type name");
  777.  
  778.   while (*p && *p != ' ' && *p != '\t') p++;
  779.   len = p - typename;
  780.   while (*p == ' ' || *p == '\t') p++;
  781.  
  782.   if (len == 6 && !strncmp (typename, "struct", 6))
  783.     type = lookup_struct (p, b);
  784.   else if (len == 5 && !strncmp (typename, "union", 5))
  785.     type = lookup_union (p, b);
  786.   else if (len == 4 && !strncmp (typename, "enum", 4))
  787.     type = lookup_enum (p, b);
  788.   else
  789.     {
  790.       type = lookup_typename (typename, b, 1);
  791.       if (type == 0)
  792.     {
  793.       register struct symbol *sym
  794.         = lookup_symbol (typename, b, STRUCT_NAMESPACE);
  795.       if (sym == 0)
  796.         error ("No type named %s.", typename);
  797.      printf_filtered ("No type named %s, but there is a ",
  798.           typename);
  799.       switch (TYPE_CODE (SYMBOL_TYPE (sym)))
  800.         {
  801.         case TYPE_CODE_STRUCT:
  802.          printf_filtered ("struct");
  803.           break;
  804.  
  805.         case TYPE_CODE_UNION:
  806.          printf_filtered ("union");
  807.           break;
  808.  
  809.         case TYPE_CODE_ENUM:
  810.          printf_filtered ("enum");
  811.           break;
  812.  
  813.         default:
  814.          printf_filtered ("(Internal error in gdb)");
  815.           break;
  816.         }
  817.      printf_filtered (" %s.  Type \"help ptype\".\n", typename);
  818.       type = SYMBOL_TYPE (sym);
  819.     }
  820.     }
  821.  
  822.   type_print (type, "", stdout, 1);
  823.  printf_filtered ("\n");
  824. }
  825.  
  826. struct display
  827. {
  828.   /* Chain link to next auto-display item.  */
  829.   struct display *next;
  830.   /* Expression to be evaluated and displayed.  */
  831.   struct expression *exp;
  832.   /* Item number of this auto-display item.  */
  833.   int number;
  834.   /* Display format specified.  */
  835.   struct format_data format;
  836.   /* Block in which expression is to be evaluated.  */
  837.   struct block *block;
  838. };
  839.  
  840. /* Chain of expressions whose values should be displayed
  841.    automatically each time the program stops.  */
  842.  
  843. static struct display *display_chain;
  844.  
  845. static int display_number;
  846.  
  847. /* Add an expression to the auto-display chain.
  848.    Specify the expression.  */
  849.  
  850. static void
  851. display_command (exp, from_tty)
  852.      char *exp;
  853.      int from_tty;
  854. {
  855.   struct format_data fmt;
  856.   register struct expression *expr;
  857.   register struct display *new;
  858.  
  859.   if (exp == 0)
  860.     {
  861.       do_displays ();
  862.       return;
  863.     }
  864.  
  865.   if (*exp == '/')
  866.     {
  867.       exp++;
  868.       fmt = decode_format (&exp, 0, 0);
  869.       if (fmt.size && fmt.format == 0)
  870.     fmt.format = 'x';
  871.       if (fmt.format == 'i' || fmt.format == 's')
  872.     fmt.size = 'b';
  873.     }
  874.   else
  875.     {
  876.       fmt.format = 0;
  877.       fmt.size = 0;
  878.       fmt.count = 0;
  879.     }
  880.  
  881.   expr = parse_c_expression (exp);
  882.  
  883.   new = (struct display *) xmalloc (sizeof (struct display));
  884.  
  885.   new->exp = expr;
  886.   new->next = display_chain;
  887.   new->number = ++display_number;
  888.   new->format = fmt;
  889.   display_chain = new;
  890.  
  891.   if (from_tty)
  892.     do_one_display (new);
  893.  
  894.   dont_repeat ();
  895. }
  896.  
  897. static void
  898. free_display (d)
  899.      struct display *d;
  900. {
  901.   free (d->exp);
  902.   free (d);
  903. }
  904.  
  905. /* Clear out the display_chain.
  906.    Done when new symtabs are loaded, since this invalidates
  907.    the types stored in many expressions.  */
  908.  
  909. void
  910. clear_displays ()
  911. {
  912.   register struct display *d;
  913.  
  914.   while (d = display_chain)
  915.     {
  916.       free (d->exp);
  917.       display_chain = d->next;
  918.       free (d);
  919.     }
  920. }
  921.  
  922. /* Delete the auto-display number NUM.  */
  923.  
  924. void
  925. delete_display (num)
  926.      int num;
  927. {
  928.   register struct display *d1, *d;
  929.  
  930.   if (!display_chain)
  931.     error ("No display number %d.", num);
  932.  
  933.   if (display_chain->number == num)
  934.     {
  935.       d1 = display_chain;
  936.       display_chain = d1->next;
  937.       free_display (d1);
  938.     }
  939.   else
  940.     for (d = display_chain; ; d = d->next)
  941.       {
  942.     if (d->next == 0)
  943.       error ("No display number %d.", num);
  944.     if (d->next->number == num)
  945.       {
  946.         d1 = d->next;
  947.         d->next = d1->next;
  948.         free_display (d1);
  949.         break;
  950.       }
  951.       }
  952. }
  953.  
  954. /* Delete some values from the auto-display chain.
  955.    Specify the element numbers.  */
  956.  
  957. static void
  958. undisplay_command (args)
  959.      char *args;
  960. {
  961.   register char *p = args;
  962.   register char *p1;
  963.   register int num;
  964.   register struct display *d, *d1;
  965.  
  966.   if (args == 0)
  967.     {
  968.       if (query ("Delete all auto-display expressions? "))
  969.     clear_displays ();
  970.       dont_repeat ();
  971.       return;
  972.     }
  973.  
  974.   while (*p)
  975.     {
  976.       p1 = p;
  977.       while (*p1 >= '0' && *p1 <= '9') p1++;
  978.       if (*p1 && *p1 != ' ' && *p1 != '\t')
  979.     error ("Arguments must be display numbers.");
  980.  
  981.       num = atoi (p);
  982.  
  983.       delete_display (num);
  984.  
  985.       p = p1;
  986.       while (*p == ' ' || *p == '\t') p++;
  987.     }
  988.   dont_repeat ();
  989. }
  990.  
  991. /* Display a single auto-display.  */
  992.  
  993. static void
  994. do_one_display (d)
  995.      struct display *d;
  996. {
  997.   current_display_number = d->number;
  998.  
  999.  printf_filtered ("%d: ", d->number);
  1000.   if (d->format.size)
  1001.     {
  1002.      printf_filtered ("x/");
  1003.       if (d->format.count != 1)
  1004. printf_filtered ("%d", d->format.count);
  1005.      printf_filtered ("%c", d->format.format);
  1006.       if (d->format.format != 'i' && d->format.format != 's')
  1007. printf_filtered ("%c", d->format.size);
  1008.      printf_filtered (" ");
  1009.       print_expression (d->exp, stdout);
  1010.       if (d->format.count != 1)
  1011. printf_filtered ("\n");
  1012.       else
  1013. printf_filtered ("  ");
  1014.       do_examine (d->format,
  1015.           value_as_long (evaluate_expression (d->exp)));
  1016.     }
  1017.   else
  1018.     {
  1019.       if (d->format.format)
  1020. printf_filtered ("/%c ", d->format.format);
  1021.       print_expression (d->exp, stdout);
  1022.      printf_filtered (" = ");
  1023.       print_formatted (evaluate_expression (d->exp),
  1024.                d->format.format, d->format.size);
  1025.      printf_filtered ("\n");
  1026.     }
  1027.  
  1028.   fflush (stdout);
  1029.   current_display_number = -1;
  1030. }
  1031.  
  1032. /* Display all of the values on the auto-display chain.  */
  1033.  
  1034. void
  1035. do_displays ()
  1036. {
  1037.   register struct display *d;
  1038.  
  1039.   for (d = display_chain; d; d = d->next)
  1040.     do_one_display (d);
  1041. }
  1042.  
  1043. /* Delete the auto-display which we were in the process of displaying.
  1044.    This is done when there is an error or a signal.  */
  1045.  
  1046. void
  1047. delete_current_display ()
  1048. {
  1049.   if (current_display_number >= 0)
  1050.     {
  1051.       delete_display (current_display_number);
  1052.       fprintf_filtered (stderr, "Deleting display %d to avoid infinite recursion.\n",
  1053.            current_display_number);
  1054.     }
  1055.   current_display_number = -1;
  1056. }
  1057.  
  1058. static void
  1059. display_info ()
  1060. {
  1061.   register struct display *d;
  1062.  
  1063.   if (!display_chain)
  1064.    printf_filtered ("There are no auto-display expressions now.\n");
  1065.   else
  1066.    printf_filtered ("Auto-display expressions now in effect:\n");
  1067.   for (d = display_chain; d; d = d->next)
  1068.     {
  1069.      printf_filtered ("%d: ", d->number);
  1070.       if (d->format.size)
  1071. printf_filtered ("/%d%c%c ", d->format.count, d->format.size,
  1072.         d->format.format);
  1073.       else if (d->format.format)
  1074. printf_filtered ("/%c ", d->format.format);
  1075.       print_expression (d->exp, stdout);
  1076.      printf_filtered ("\n");
  1077.       fflush (stdout);
  1078.     }
  1079. }
  1080.  
  1081. /* Print the value in stack frame FRAME of a variable
  1082.    specified by a struct symbol.  */
  1083.  
  1084. void
  1085. print_variable_value (var, frame, stream)
  1086.      struct symbol *var;
  1087.      CORE_ADDR frame;
  1088.      FILE *stream;
  1089. {
  1090.   value val = read_var_value (var, frame);
  1091.   value_print (val, stream, 0);
  1092. }
  1093.  
  1094. /* Print the arguments of a stack frame, given the function FUNC
  1095.    running in that frame (as a symbol), the address of the arglist,
  1096.    and the number of args according to the stack frame (or -1 if unknown).  */
  1097.  
  1098. static void print_frame_nameless_args ();
  1099.  
  1100. print_frame_args (func, addr, num, stream)
  1101.      struct symbol *func;
  1102.      register CORE_ADDR addr;
  1103.      int num;
  1104.      FILE *stream;
  1105. {
  1106.   struct block *b;
  1107.   int nsyms = 0;
  1108.   int first = 1;
  1109.   register int i;
  1110.   register int last_offset = FRAME_ARGS_SKIP;
  1111.   register struct symbol *sym, *nextsym;
  1112.   register value val;
  1113.  
  1114.   if (func)
  1115.     {
  1116.       b = SYMBOL_BLOCK_VALUE (func);
  1117.       nsyms = BLOCK_NSYMS (b);
  1118.     }
  1119.  
  1120.   while (1)
  1121.     {
  1122.       /* Find first arg that is not before LAST_OFFSET.  */
  1123.       nextsym = 0;
  1124.       for (i = 0; i < nsyms; i++)
  1125.     {
  1126.       QUIT;
  1127.       sym = BLOCK_SYM (b, i);
  1128.       if (SYMBOL_CLASS (sym) == LOC_ARG
  1129.           && SYMBOL_VALUE (sym) >= last_offset
  1130.           && (nextsym == 0
  1131.           || SYMBOL_VALUE (sym) < SYMBOL_VALUE (nextsym)))
  1132.         nextsym = sym;
  1133.     }
  1134.       if (nextsym == 0)
  1135.     break;
  1136.       sym = nextsym;
  1137.       /* Print any nameless args between the last arg printed
  1138.      and the next arg.  */
  1139.       if (last_offset != (SYMBOL_VALUE (sym) / sizeof (int)) * sizeof (int))
  1140.     {
  1141.       print_frame_nameless_args (addr, last_offset, SYMBOL_VALUE (sym),
  1142.                      stream);
  1143.       first = 0;
  1144.     }
  1145.       /* Print the next arg.  */
  1146.       val = value_at (SYMBOL_TYPE (sym), addr + SYMBOL_VALUE (sym));
  1147.       if (! first)
  1148.     fprintf_filtered (stream, ", ");
  1149.       fprintf_filtered (stream, "%s=", SYMBOL_NAME (sym));
  1150.       value_print (val, stream, 0);
  1151.       first = 0;
  1152.       last_offset = SYMBOL_VALUE (sym) + TYPE_LENGTH (SYMBOL_TYPE (sym));
  1153.       /* Round up address of next arg to multiple of size of int.  */
  1154.       if(gcc_mshort)
  1155.       last_offset
  1156.       = ((last_offset + sizeof (short) - 1) / sizeof (short)) * sizeof (short);
  1157.       else
  1158.       last_offset
  1159.         = ((last_offset + sizeof (int) - 1) / sizeof (int)) * sizeof (int);
  1160.     }
  1161.   if (num >= 0 && num * sizeof (int) + FRAME_ARGS_SKIP > last_offset)
  1162.     print_frame_nameless_args (addr, last_offset,
  1163.                    num * sizeof (int) + FRAME_ARGS_SKIP, stream);
  1164. }
  1165.  
  1166. static void
  1167. print_frame_nameless_args (argsaddr, start, end, stream)
  1168.      CORE_ADDR argsaddr;
  1169.      int start;
  1170.      int end;
  1171.      FILE *stream;
  1172. {
  1173.   while (start < end)
  1174.     {
  1175.       QUIT;
  1176.       if (start != FRAME_ARGS_SKIP)
  1177.     fprintf_filtered (stream, ", ");
  1178.       fprintf_filtered (stream, "%d",
  1179.            read_memory_integer (argsaddr + start, sizeof (int)));
  1180.       start += sizeof (int);
  1181.     }
  1182. }
  1183.  
  1184. static void
  1185. printf_command (arg)
  1186.      char *arg;
  1187. {
  1188.   register char *f;
  1189.   register char *s = arg;
  1190.   char *string;
  1191.   value *val_args;
  1192.   int nargs = 0;
  1193.   int allocated_args = 20;
  1194.   char *arg_bytes;
  1195.   char *argclass;
  1196.   int i;
  1197.   int argindex;
  1198.   int nargs_wanted;
  1199.  
  1200.   val_args = (value *) xmalloc (allocated_args * sizeof (value));
  1201.  
  1202.   if (s == 0)
  1203.     error_no_arg ("format-control string and values to print");
  1204.  
  1205.   /* Skip white space before format string */
  1206.   while (*s == ' ' || *s == '\t') s++;
  1207.  
  1208.   /* A format string should follow, enveloped in double quotes */
  1209.   if (*s++ != '"')
  1210.     error ("Bad format string, missing '\"'.");
  1211.  
  1212.   /* Parse the format-control string and copy it into the string STRING,
  1213.      processing some kinds of escape sequence.  */
  1214.  
  1215.   f = string = (char *) alloca (strlen (s) + 1);
  1216.   while (*s != '"')
  1217.     {
  1218.       int c = *s++;
  1219.       switch (c)
  1220.     {
  1221.     case '\0':
  1222.       error ("Bad format string, non-terminated '\"'.");
  1223.       /* doesn't return */
  1224.  
  1225.     case '\\':
  1226.       switch (c = *s++)
  1227.         {
  1228.         case '\\':
  1229.           *f++ = '\\';
  1230.           break;
  1231.         case 'n':
  1232.           *f++ = '\n';
  1233.           break;
  1234.         case 't':
  1235.           *f++ = '\t';
  1236.           break;
  1237.         case 'r':
  1238.           *f++ = '\r';
  1239.           break;
  1240.         case '"':
  1241.           *f++ = '"';
  1242.           break;
  1243.         default:
  1244.           /* ??? TODO: handle other escape sequences */
  1245.           error ("Unrecognized \\ escape character in format string.");
  1246.         }
  1247.       break;
  1248.  
  1249.     default:
  1250.       *f++ = c;
  1251.     }
  1252.     }
  1253.  
  1254.   /* Skip over " and following space and comma.  */
  1255.   s++;
  1256.   *f++ = '\0';
  1257.   while (*s == ' ' || *s == '\t') s++;
  1258.  
  1259.   if (*s != ',' && *s != 0)
  1260.     error ("Invalid argument syntax");
  1261.  
  1262.   if (*s == ',') s++;
  1263.   while (*s == ' ' || *s == '\t') s++;
  1264.  
  1265.   /* Now scan the string for %-specs and see what kinds of args they want.
  1266.      argclass[I] is set to 1 if the Ith arg should be a string.  */
  1267.  
  1268.   argclass = (char *) alloca (strlen (s));
  1269.   nargs_wanted = 0;
  1270.   f = string;
  1271.   while (*f)
  1272.     if (*f++ == '%')
  1273.       {
  1274.     while (index ("0123456789.hlL-+ #", *f)) f++;
  1275.     if (*f == 's')
  1276.       argclass[nargs_wanted++] = 1;
  1277.     else if (*f != '%')
  1278.       argclass[nargs_wanted++] = 0;
  1279.     f++;
  1280.       }
  1281.  
  1282.   /* Now, parse all arguments and evaluate them.
  1283.      Store the VALUEs in VAL_ARGS.  */
  1284.  
  1285.   while (*s != '\0')
  1286.     {
  1287.       char *s1;
  1288.       if (nargs == allocated_args)
  1289.     val_args = (value *) xrealloc (val_args,
  1290.                        (allocated_args *= 2)
  1291.                        * sizeof (value));
  1292.       s1 = s;
  1293.       val_args[nargs++] = parse_to_comma_and_eval (&s1);
  1294.       s = s1;
  1295.       if (*s == ',')
  1296.     s++;
  1297.     }
  1298.  
  1299.   if (nargs != nargs_wanted)
  1300.     error ("Wrong number of arguments for specified format-string");
  1301.  
  1302.   /* Now lay out an argument-list containing the arguments
  1303.      as doubles, integers and C pointers.  */
  1304.  
  1305.   arg_bytes = (char *) alloca (sizeof (double) * nargs);
  1306.   argindex = 0;
  1307.   for (i = 0; i < nargs; i++)
  1308.     {
  1309.       if (argclass[i])
  1310.     {
  1311.       char *str;
  1312.       int tem, j;
  1313.       tem = value_as_long (val_args[i]);
  1314.  
  1315.       /* This is a %s argument.  Find the length of the string.  */
  1316.       for (j = 0; ; j++)
  1317.         {
  1318.           char c;
  1319.           QUIT;
  1320.           read_memory (tem + j, &c, 1);
  1321.           if (c == 0)
  1322.         break;
  1323.         }
  1324.  
  1325.       /* Copy the string contents into a string inside GDB.  */
  1326.       str = (char *) alloca (j + 1);
  1327.       read_memory (tem, str, j);
  1328.       str[j] = 0;
  1329.  
  1330.       /* Pass address of internal copy as the arg to printf_filtered.  */
  1331.       *((int *) &arg_bytes[argindex]) = (int) str;
  1332.       argindex += sizeof (int);
  1333.     }
  1334.       else if (VALUE_TYPE (val_args[i])->code == TYPE_CODE_FLT)
  1335.     {
  1336.       *((double *) &arg_bytes[argindex]) = value_as_double (val_args[i]);
  1337.       argindex += sizeof (double);
  1338.     }
  1339.       else
  1340.     {
  1341.       *((int *) &arg_bytes[argindex]) = value_as_long (val_args[i]);
  1342.       argindex += sizeof (int);
  1343.     }
  1344.     }
  1345.  
  1346.   printf_filtered (string, arg_bytes);
  1347. }
  1348.  
  1349. /* Helper function for asdump_command.  Finds the bounds of a function
  1350.    for a specified section of text.  PC is an address within the
  1351.    function which you want bounds for; *LOW and *HIGH are set to the
  1352.    beginning (inclusive) and end (exclusive) of the function.  This
  1353.    function returns 1 on success and 0 on failure.  */
  1354.  
  1355. static int
  1356. containing_function_bounds (pc, low, high)
  1357.      CORE_ADDR pc, *low, *high;
  1358. {
  1359.   int scan;
  1360.  
  1361.   if (!find_pc_partial_function (pc, 0, low))
  1362.     return 0;
  1363.  
  1364.   scan = *low;
  1365.   do {
  1366.     scan++;
  1367.     if (!find_pc_partial_function (scan, 0, high))
  1368.       return 0;
  1369.   } while (*low == *high);
  1370.  
  1371.   return 1;
  1372. }
  1373.  
  1374. /* Dump a specified section of assembly code.  With no command line
  1375.    arguments, this command will dump the assembly code for the
  1376.    function surrounding the pc value in the selected frame.  With one
  1377.    argument, it will dump the assembly code surrounding that pc value.
  1378.    Two arguments are interpeted as bounds within which to dump
  1379.    assembly.  */
  1380.  
  1381. /* ARGSUSED */
  1382. static void
  1383. disassemble_command (arg, from_tty)
  1384.      char *arg;
  1385.      int from_tty;
  1386. {
  1387.   CORE_ADDR low, high;
  1388.   CORE_ADDR pc;
  1389.   char *space_index;
  1390.  
  1391.   if (!arg)
  1392.     {
  1393.       if (!selected_frame)
  1394.     error ("No frame selected.\n");
  1395.  
  1396.       pc = get_frame_pc (selected_frame);
  1397.       if (!containing_function_bounds (pc, &low, &high))
  1398.     error ("No function contains pc specified by selected frame.\n");
  1399.     }
  1400.   else if (!(space_index = (char *) index (arg, ' ')))
  1401.     {
  1402.       /* One argument.  */
  1403.       pc = parse_and_eval_address (arg);
  1404.       if (!containing_function_bounds (pc, &low, &high))
  1405.     error ("No function contains specified pc.\n");
  1406.     }
  1407.   else
  1408.     {
  1409.       /* Two arguments.  */
  1410.       *space_index = '\0';
  1411.       low = parse_and_eval_address (arg);
  1412.       high = parse_and_eval_address (space_index + 1);
  1413.     }
  1414.  
  1415.  printf_filtered ("Dump of assembler code ");
  1416.   if (!space_index)
  1417.     {
  1418.       char *name;
  1419.       find_pc_partial_function (pc, &name, 0);
  1420.      printf_filtered ("for function %s:\n", name);
  1421.     }
  1422.   else
  1423.    printf_filtered ("from 0x%x to 0x%x:\n", low, high);
  1424.  
  1425.   /* Dump the specified range.  */
  1426.   for (pc = low; pc < high; )
  1427.     {
  1428.       QUIT;
  1429.       print_address (pc, stdout);
  1430.      printf_filtered (":\t");
  1431.       pc += print_insn (pc, stdout);
  1432.      printf_filtered ("\n");
  1433.     }
  1434.  printf_filtered ("End of assembler dump.\n");
  1435.   fflush (stdout);
  1436. }
  1437.  
  1438. void
  1439. initialize_printcmd ()
  1440. {
  1441.   current_display_number = -1;
  1442.  
  1443.   add_info ("address", address_info,
  1444.        "Describe where variable VAR is stored.");
  1445.  
  1446.   add_com ("x", class_vars, x_command,
  1447.        "Examine memory: x/FMT ADDRESS.\n\
  1448. ADDRESS is an expression for the memory address to examine.\n\
  1449. FMT is a repeat count followed by a format letter and a size letter.\n\
  1450. Format letters are o(octal), x(hex), d(decimal), u(unsigned decimal),\n\
  1451.  f(float), a(address), i(instruction), c(char) and s(string).\n\
  1452. Size letters are b(byte), h(halfword), w(word), g(giant, 8 bytes).\n\
  1453.   g is meaningful only with f, for type double.\n\
  1454. The specified number of objects of the specified size are printed\n\
  1455. according to the format.\n\n\
  1456. Defaults for format and size letters are those previously used.\n\
  1457. Default count is 1.  Default address is following last thing printed\n\
  1458. with this command or \"print\".");
  1459.  
  1460.   add_com ("disassemble", class_vars, disassemble_command,
  1461.        "Disassemble a specified section of memory.\n\
  1462. Default is the function surrounding the pc of the selected frame.\n\
  1463. With a single argument, the function surrounding that address is dumped.\n\
  1464. Two arguments are taken as a range of memory to dump.");
  1465.  
  1466.   add_com ("ptype", class_vars, ptype_command,
  1467.        "Print definition of type TYPE.\n\
  1468. Argument may be a type name defined by typedef, or \"struct STRUCTNAME\"\n\
  1469. or \"union UNIONNAME\" or \"enum ENUMNAME\".\n\
  1470. The selected stack frame's lexical context is used to look up the name.");
  1471.  
  1472.   add_com ("whatis", class_vars, whatis_command,
  1473.        "Print data type of expression EXP.");
  1474.  
  1475.   add_info ("display", display_info,
  1476.         "Expressions to display when program stops, with code numbers.");
  1477.   add_com ("undisplay", class_vars, undisplay_command,
  1478.        "Cancel some expressions to be displayed whenever program stops.\n\
  1479. Arguments are the code numbers of the expressions to stop displaying.\n\
  1480. No argument means cancel all automatic-display expressions.\n\
  1481. Do \"info display\" to see current list of code numbers.");
  1482.   add_com ("display", class_vars, display_command,
  1483.        "Print value of expression EXP each time the program stops.\n\
  1484. /FMT may be used before EXP as in the \"print\" command.\n\
  1485. /FMT \"i\" or \"s\" or including a size-letter is allowed,\n\
  1486. as in the \"x\" command, and then EXP is used to get the address to examine\n\
  1487. and examining is done as in the \"x\" command.\n\n\
  1488. With no argument, display all currently requested auto-display expressions.\n\
  1489. Use \"undisplay\" to cancel display requests previously made.");
  1490.  
  1491.   add_com ("printf", class_vars, printf_command,
  1492.     "printf \"printf format string\", arg1, arg2, arg3, ..., argn\n\
  1493. This is useful for formatted output in user-defined commands.");
  1494.   add_com ("output", class_vars, output_command,
  1495.        "Like \"print\" but don't put in value history and don't print newline.\n\
  1496. This is useful in user-defined commands.");
  1497.  
  1498.   add_com ("set", class_vars, set_command,
  1499.        "Perform an assignment VAR = EXP.  You must type the \"=\".\n\
  1500. VAR may be a debugger \"convenience\" variables (names starting with $),\n\
  1501. a register (a few standard names starting with $), or an actual variable\n\
  1502. in the program being debugger.  EXP is any expression.");
  1503.  
  1504.   add_com ("print", class_vars, print_command,
  1505.        concat ("Print value of expression EXP.\n\
  1506. Variables accessible are those of the lexical environment of the selected\n\
  1507. stack frame, plus all those whose scope is global or an entire file.\n\
  1508. \n\
  1509. $NUM gets previous value number NUM.  $ and $$ are the last two values.\n\
  1510. $$NUM refers to NUM'th value back from the last one.\n\
  1511. Names starting with $ refer to registers (with the values they would have\n\
  1512. if the program were to return to the stack frame now selected, restoring\n\
  1513. all registers saved by frames farther in) or else to debugger\n\
  1514. \"convenience\" variables (any such name not a known register).\n\
  1515. Use assignment expressions to give values to convenience variables.\n",
  1516.            "\n\
  1517. \{TYPE}ADREXP refers to a datum of data type TYPE, located at address ADREXP.\n\
  1518. @ is a binary operator for treating consecutive data objects\n\
  1519. anywhere in memory as an array.  FOO@NUM gives an array whose first\n\
  1520. element is FOO, whose second element is stored in the space following\n\
  1521. where FOO is stored, etc.  FOO must be an expression whose value\n\
  1522. resides in memory.\n",
  1523.            "\n\
  1524. EXP may be preceded with /FMT, where FMT is a format letter\n\
  1525. but no count or size letter (see \"x\" command)."));
  1526.   add_com_alias ("p", "print", class_vars, 1);
  1527. }
  1528.