home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gdb-4.12-src.lha
/
GNU
/
src
/
amiga
/
gdb-4.12
/
gdb
/
printcmd.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-03
|
59KB
|
2,159 lines
/* Print values for GNU debugger GDB.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1993, 1994
Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "defs.h"
#include <string.h>
#include <varargs.h>
#include "frame.h"
#include "symtab.h"
#include "gdbtypes.h"
#include "value.h"
#include "language.h"
#include "expression.h"
#include "gdbcore.h"
#include "gdbcmd.h"
#include "target.h"
#include "breakpoint.h"
#include "demangle.h"
#include "valprint.h"
extern int asm_demangle; /* Whether to demangle syms in asm printouts */
extern int addressprint; /* Whether to print hex addresses in HLL " */
struct format_data
{
int count;
char format;
char size;
};
/* Last specified output format. */
static char last_format = 'x';
/* Last specified examination size. 'b', 'h', 'w' or `q'. */
static char last_size = 'w';
/* Default address to examine next. */
static CORE_ADDR next_address;
/* Last address examined. */
static CORE_ADDR last_examine_address;
/* Contents of last address examined.
This is not valid past the end of the `x' command! */
static value last_examine_value;
/* Largest offset between a symbolic value and an address, that will be
printed as `0x1234 <symbol+offset>'. */
static unsigned int max_symbolic_offset = UINT_MAX;
/* Append the source filename and linenumber of the symbol when
printing a symbolic value as `<symbol at filename:linenum>' if set. */
static int print_symbol_filename = 0;
/* Switch for quick display of symbolic addresses -- only uses minsyms,
not full search of symtabs. */
int fast_symbolic_addr = 1;
/* Number of auto-display expression currently being displayed.
So that we can disable it if we get an error or a signal within it.
-1 when not doing one. */
int current_display_number;
/* Flag to low-level print routines that this value is being printed
in an epoch window. We'd like to pass this as a parameter, but
every routine would need to take it. Perhaps we can encapsulate
this in the I/O stream once we have GNU stdio. */
int inspect_it = 0;
struct display
{
/* Chain link to next auto-display item. */
struct display *next;
/* Expression to be evaluated and displayed. */
struct expression *exp;
/* Item number of this auto-display item. */
int number;
/* Display format specified. */
struct format_data format;
/* Innermost block required by this expression when evaluated */
struct block *block;
/* Status of this display (enabled or disabled) */
enum enable status;
};
/* Chain of expressions whose values should be displayed
automatically each time the program stops. */
static struct display *display_chain;
static int display_number;
/* Prototypes for local functions */
static void
delete_display PARAMS ((int));
static void
enable_display PARAMS ((char *, int));
static void
disable_display_command PARAMS ((char *, int));
static void
disassemble_command PARAMS ((char *, int));
static void
printf_command PARAMS ((char *, int));
static void
print_frame_nameless_args PARAMS ((struct frame_info *, long, int, int,
GDB_FILE *));
static void
display_info PARAMS ((char *, int));
static void
do_one_display PARAMS ((struct display *));
static void
undisplay_command PARAMS ((char *, int));
static void
free_display PARAMS ((struct display *));
static void
display_command PARAMS ((char *, int));
static void
x_command PARAMS ((char *, int));
static void
address_info PARAMS ((char *, int));
static void
set_command PARAMS ((char *, int));
static void
output_command PARAMS ((char *, int));
static void
call_command PARAMS ((char *, int));
static void
inspect_command PARAMS ((char *, int));
static void
print_command PARAMS ((char *, int));
static void
print_command_1 PARAMS ((char *, int, int));
static void
validate_format PARAMS ((struct format_data, char *));
static void
do_examine PARAMS ((struct format_data, CORE_ADDR));
static void
print_formatted PARAMS ((value, int, int));
static struct format_data
decode_format PARAMS ((char **, int, int));
/* Decode a format specification. *STRING_PTR should point to it.
OFORMAT and OSIZE are used as defaults for the format and size
if none are given in the format specification.
If OSIZE is zero, then the size field of the returned value
should be set only if a size is explicitly specified by the
user.
The structure returned describes all the data
found in the specification. In addition, *STRING_PTR is advanced
past the specification and past all whitespace following it. */
static struct format_data
decode_format (string_ptr, oformat, osize)
char **string_ptr;
int oformat;
int osize;
{
struct format_data val;
register char *p = *string_ptr;
val.format = '?';
val.size = '?';
val.count = 1;
if (*p >= '0' && *p <= '9')
val.count = atoi (p);
while (*p >= '0' && *p <= '9') p++;
/* Now process size or format letters that follow. */
while (1)
{
if (*p == 'b' || *p == 'h' || *p == 'w' || *p == 'g')
val.size = *p++;
else if (*p >= 'a' && *p <= 'z')
val.format = *p++;
else
break;
}
#ifndef CC_HAS_LONG_LONG
/* Make sure 'g' size is not used on integer types.
Well, actually, we can handle hex. */
if (val.size == 'g' && val.format != 'f' && val.format != 'x')
val.size = 'w';
#endif
while (*p == ' ' || *p == '\t') p++;
*string_ptr = p;
/* Set defaults for format and size if not specified. */
if (val.format == '?')
{
if (val.size == '?')
{
/* Neither has been specified. */
val.format = oformat;
val.size = osize;
}
else
/* If a size is specified, any format makes a reasonable
default except 'i'. */
val.format = oformat == 'i' ? 'x' : oformat;
}
else if (val.size == '?')
switch (val.format)
{
case 'a':
case 's':
/* Addresses must be words. */
val.size = osize ? 'w' : osize;
break;
case 'f':
/* Floating point has to be word or giantword. */
if (osize == 'w' || osize == 'g')
val.size = osize;
else
/* Default it to giantword if the last used size is not
appropriate. */
val.size = osize ? 'g' : osize;
break;
case 'c':
/* Characters default to one byte. */
val.size = osize ? 'b' : osize;
break;
default:
/* The default is the size most recently specified. */
val.size = osize;
}
return val;
}
/* Print value VAL on gdb_stdout according to FORMAT, a letter or 0.
Do not end with a newline.
0 means print VAL according to its own type.
SIZE is the letter for the size of datum being printed.
This is used to pad hex numbers so they line up. */
static void
print_formatted (val, format, size)
register value val;
register int format;
int size;
{
int len = TYPE_LENGTH (VALUE_TYPE (val));
if (VALUE_LVAL (val) == lval_memory)
next_address = VALUE_ADDRESS (val) + len;
switch (format)
{
case 's':
next_address = VALUE_ADDRESS (val)
+ value_print (value_addr (val), gdb_stdout, format, Val_pretty_default);
break;
case 'i':
/* The old comment says
"Force output out, print_insn not using _filtered".
I'm not completely sure what that means, I suspect most print_insn
now do use _filtered, so I guess it's obsolete. */
/* We often wrap here if there are long symbolic names. */
wrap_here (" ");
next_address = VALUE_ADDRESS (val)
+ print_insn (VALUE_ADDRESS (val), gdb_stdout);
brea