#include "frame.h"
#include "symtab.h"
#include "value.h"
+#include "language.h"
#include "expression.h"
#include "gdbcore.h"
#include "gdbcmd.h"
break;
case 'i':
+ wrap_here (""); /* Force output out, print_insn not using _filtered */
next_address = VALUE_ADDRESS (val)
+ print_insn (VALUE_ADDRESS (val), stdout);
break;
{
/* ok, we're going to have to get fancy here. Assumption: a
long is four bytes. FIXME. */
- unsigned long v1, v2, tmp;
+ unsigned long v1, v2;
v1 = unpack_long (builtin_type_long, valaddr);
v2 = unpack_long (builtin_type_long, valaddr + 4);
#if TARGET_BYTE_ORDER == LITTLE_ENDIAN
/* Swap the two for printing */
- tmp = v1;
- v1 = v2;
- v2 = tmp;
+ {
+ unsigned long tmp;
+
+ tmp = v1;
+ v1 = v2;
+ v2 = tmp;
+ }
#endif
switch (format)
{
case 'x':
- fprintf_filtered (stream, "0x%08x%08x", v1, v2);
+ fprintf_filtered (stream, local_hex_format_custom("08x%08"), v1, v2);
break;
default:
error ("Output size \"g\" unimplemented for format \"%c\".",
{
/* no size specified, like in print. Print varying # of digits. */
#if defined (LONG_LONG)
- fprintf_filtered (stream, "0x%llx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("ll"), val_long);
#else /* not LONG_LONG. */
- fprintf_filtered (stream, "0x%lx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("l"), val_long);
#endif /* not LONG_LONG. */
}
else
switch (size)
{
case 'b':
- fprintf_filtered (stream, "0x%02llx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("02ll"), val_long);
break;
case 'h':
- fprintf_filtered (stream, "0x%04llx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("04ll"), val_long);
break;
case 'w':
- fprintf_filtered (stream, "0x%08llx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("08ll"), val_long);
break;
case 'g':
- fprintf_filtered (stream, "0x%016llx", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("016ll"), val_long);
break;
default:
error ("Undefined output size \"%c\".", size);
switch (size)
{
case 'b':
- fprintf_filtered (stream, "0x%02x", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("02"), val_long);
break;
case 'h':
- fprintf_filtered (stream, "0x%04x", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("04"), val_long);
break;
case 'w':
- fprintf_filtered (stream, "0x%08x", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("08"), val_long);
break;
case 'g':
- fprintf_filtered (stream, "0x%016x", val_long);
+ fprintf_filtered (stream, local_hex_format_custom("016"), val_long);
break;
default:
error ("Undefined output size \"%c\".", size);
case 'o':
if (val_long)
#ifdef LONG_LONG
- fprintf_filtered (stream, "0%llo", val_long);
+ fprintf_filtered (stream, local_octal_format_custom("ll"), val_long);
#else
- fprintf_filtered (stream, "0%o", val_long);
+ fprintf_filtered (stream, local_octal_format(), val_long);
#endif
else
fprintf_filtered (stream, "0");
break;
case 'c':
- value_print (value_from_long (builtin_type_char, val_long), stream, 0,
+ value_print (value_from_longest (builtin_type_char, val_long), stream, 0,
Val_pretty_default);
break;
/* Make address available to the user as $_. */
set_internalvar (lookup_internalvar ("_"),
- value_from_long (builtin_type_int, (LONGEST) addr));
+ value_from_longest (lookup_pointer_type (builtin_type_void),
+ (LONGEST) addr));
}
/* Optionally print address ADDR symbolically as <SYMBOL+OFFSET> on STREAM,
CORE_ADDR addr;
FILE *stream;
{
- fprintf_filtered (stream, "0x%x", addr);
+ fprintf_filtered (stream, local_hex_format(), addr);
print_address_symbolic (addr, stream, asm_demangle, " ");
}
if (addr == 0) {
fprintf_filtered (stream, "0");
} else if (addressprint) {
- fprintf_filtered (stream, "0x%x", addr);
+ fprintf_filtered (stream, local_hex_format(), addr);
print_address_symbolic (addr, stream, do_demangle, " ");
} else {
print_address_symbolic (addr, stream, do_demangle, "");
{
extern int objectprint;
struct type *type;
- expr = parse_c_expression (exp);
+ expr = parse_expression (exp);
old_chain = make_cleanup (free_current_contents, &expr);
cleanup = 1;
val = evaluate_expression (expr);
format = fmt.format;
}
- expr = parse_c_expression (exp);
+ expr = parse_expression (exp);
old_chain = make_cleanup (free_current_contents, &expr);
val = evaluate_expression (expr);
char *exp;
int from_tty;
{
- struct expression *expr = parse_c_expression (exp);
+ struct expression *expr = parse_expression (exp);
register struct cleanup *old_chain
= make_cleanup (free_current_contents, &expr);
evaluate_expression (expr);
break;
if (i < misc_function_count)
- printf ("Symbol \"%s\" is at 0x%x in a file compiled without -g.\n",
- exp, misc_function_vector[i].address);
+ printf ("Symbol \"%s\" is at %s in a file compiled without debugging.\n",
+ exp, local_hex_string(misc_function_vector[i].address));
else
error ("No symbol \"%s\" in current context.", exp);
return;
break;
case LOC_LABEL:
- printf ("a label at address 0x%x", SYMBOL_VALUE_ADDRESS (sym));
+ printf ("a label at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym)));
break;
case LOC_REGISTER:
break;
case LOC_STATIC:
- printf ("static at address 0x%x", SYMBOL_VALUE_ADDRESS (sym));
+ printf ("static storage at address %s", local_hex_string(SYMBOL_VALUE_ADDRESS (sym)));
break;
case LOC_REGPARM:
break;
case LOC_BLOCK:
- printf ("a function at address 0x%x",
- BLOCK_START (SYMBOL_BLOCK_VALUE (sym)));
- break;
-
- case LOC_EXTERNAL:
- printf ("an external symbol at address 0x%x",
- SYMBOL_VALUE_ADDRESS (sym));
+ printf ("a function at address %s",
+ local_hex_string(BLOCK_START (SYMBOL_BLOCK_VALUE (sym))));
break;
default:
if (exp != 0 && *exp != 0)
{
- expr = parse_c_expression (exp);
+ expr = parse_expression (exp);
/* Cause expression not to be there any more
if this command is repeated with Newline.
But don't clobber a user-defined command's definition. */
/* Set a couple of internal variables if appropriate. */
if (last_examine_value)
{
- /* Make last address examined available to the user as $_. */
+ /* Make last address examined available to the user as $_. Use
+ the correct pointer type. */
set_internalvar (lookup_internalvar ("_"),
- value_from_long (builtin_type_int,
- (LONGEST) last_examine_address));
+ value_from_longest (
+ lookup_pointer_type (VALUE_TYPE (last_examine_value)),
+ (LONGEST) last_examine_address));
/* Make contents of last address examined available to the user as $__.*/
set_internalvar (lookup_internalvar ("__"), last_examine_value);
if (exp)
{
- expr = parse_c_expression (exp);
+ expr = parse_expression (exp);
old_chain = make_cleanup (free_current_contents, &expr);
val = evaluate_type (expr);
}
whatis_exp (exp, -1);
}
+/* Simple subroutine for ptype_command. */
+static
+struct type *
+ptype_eval(exp)
+ struct expression *exp;
+{
+ if(exp->elts[0].opcode==OP_TYPE)
+ return exp->elts[1].type;
+ else
+ return 0;
+}
+
/* TYPENAME is either the name of a type, or an expression. */
/* ARGSUSED */
static void
char *typename;
int from_tty;
{
- register char *p = typename;
- register int len;
- register struct block *b
- = target_has_stack ? get_current_block () : 0;
register struct type *type;
+ struct expression *expr;
+ register struct cleanup *old_chain;
- if (typename == 0)
- {
- whatis_exp (typename, 1);
- return;
- }
-
- while (*p && *p != ' ' && *p != '\t') p++;
- len = p - typename;
- while (*p == ' ' || *p == '\t') p++;
-
- if (len == 6 && !strncmp (typename, "struct", 6))
- type = lookup_struct (p, b);
- else if (len == 5 && !strncmp (typename, "union", 5))
- type = lookup_union (p, b);
- else if (len == 4 && !strncmp (typename, "enum", 4))
- type = lookup_enum (p, b);
- else
- {
- type = lookup_typename (typename, b, 1);
- if (type == 0)
- {
- register struct symbol *sym
- = lookup_symbol (typename, b, STRUCT_NAMESPACE, 0,
- (struct symtab **)NULL);
- if (sym == 0)
- {
- /* It's not the name of a type, either VAR_NAMESPACE
- or STRUCT_NAMESPACE, so it must be an expression. */
- whatis_exp (typename, 1);
- return;
- }
- printf_filtered ("No type named %s, ", typename);
- wrap_here ("");
- printf_filtered ("but there is ");
- switch (TYPE_CODE (SYMBOL_TYPE (sym)))
- {
- case TYPE_CODE_STRUCT:
- printf_filtered ("a struct");
- break;
-
- case TYPE_CODE_UNION:
- printf_filtered ("a union");
- break;
-
- case TYPE_CODE_ENUM:
- printf_filtered ("an enum");
- break;
-
- default:
- printf_filtered ("(Internal error in gdb)");
- break;
- }
- printf_filtered (" %s. ", typename);
- wrap_here ("");
- printf_filtered ("(Type \"help ptype\".)\n");
- type = SYMBOL_TYPE (sym);
- }
- }
-
- type_print (type, "", stdout, 1);
- printf_filtered ("\n");
-}
-\f
-#if 0
-/* This is not necessary. Instead, decode_line_1 takes any variable,
- so "info line foo" is a close equivalent to "whereis foo". */
-static void
-whereis_command (var, from_tty)
- char *var;
- int from_tty;
-{
- struct symtab *s;
- struct symbol *sym;
-
- if (var == NULL)
- error_no_arg ("Variable name.");
-
- sym = lookup_symbol (var, get_selected_block (), VAR_NAMESPACE,
- NULL, &s);
-
- if (sym != NULL && s != NULL)
- printf_filtered ("Symbol \"%s\" is at line %d of file %s\n",
- var, sym->line, s->filename);
+ if (typename)
+ {
+ expr = parse_expression (typename);
+ old_chain = make_cleanup (free_current_contents, &expr);
+ type = ptype_eval (expr);
+
+ if(type)
+ {
+ printf_filtered ("type = ");
+ type_print (type, "", stdout, 1);
+ printf_filtered ("\n");
+ do_cleanups (old_chain);
+ }
+ else
+ {
+ do_cleanups (old_chain);
+ whatis_exp (typename, 1);
+ }
+ }
else
- {
- if (lookup_misc_func (var) >= 0)
- printf_filtered ("Symbol \"%s\" is in a file compiled without -g.",
- var);
- else
- error ("No symbol \"%s\" in current context.", var);
- }
+ whatis_exp (typename, 1);
}
-#endif /* 0 */
\f
enum display_status {disabled, enabled};
}
innermost_block = 0;
- expr = parse_c_expression (exp);
+ expr = parse_expression (exp);
new = (struct display *) xmalloc (sizeof (struct display));
QUIT;
sym = BLOCK_SYM (b, i);
- if (SYMBOL_CLASS (sym) != LOC_REGPARM
- && SYMBOL_CLASS (sym) != LOC_ARG
- && SYMBOL_CLASS (sym) != LOC_LOCAL_ARG
- && SYMBOL_CLASS (sym) != LOC_REF_ARG)
- continue;
-
- /* We have to re-look-up the symbol because arguments often have
- two entries (one a parameter, one a register or local), and the one
- we want is the non-parm, which lookup_symbol will find for
- us. After this, sym could be any SYMBOL_CLASS... */
- sym = lookup_symbol (SYMBOL_NAME (sym),
- b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
+ /* Keep track of the highest stack argument offset seen, and
+ skip over any kinds of symbols we don't care about. */
switch (SYMBOL_CLASS (sym)) {
-
- /* Keep track of the highest stack argument offset seen */
case LOC_ARG:
case LOC_REF_ARG:
{
args_printed += (arg_size + sizeof (int) - 1) / sizeof (int);
}
- /* Other types of symbols don't need to be kept track of. */
- default:
+ /* We care about types of symbols, but don't need to keep track of
+ stack offsets in them. */
+ case LOC_REGPARM:
+ case LOC_LOCAL_ARG:
break;
+
+ /* Other types of symbols we just skip over. */
+ default:
+ continue;
}
+ /* We have to re-look-up the symbol because arguments often have
+ two entries (one a parameter, one a register or local), and the one
+ we want is the non-parm, which lookup_symbol will find for
+ us. After this, sym could be any SYMBOL_CLASS... */
+ sym = lookup_symbol (SYMBOL_NAME (sym),
+ b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
+
/* Print the current arg. */
if (! first)
fprintf_filtered (stream, ", ");
printf_filtered ("for function %s:\n", name);
}
else
- printf_filtered ("from 0x%x to 0x%x:\n", low, high);
+ printf_filtered ("from %s ", local_hex_string(low));
+ printf_filtered ("to %s:\n", local_hex_string(high));
/* Dump the specified range. */
for (pc = low; pc < high; )
/* "call" is the same as "set", but handy for dbx users to call fns. */
add_com ("call", class_vars, call_command,
"Call a function in the inferior process.\n\
-The argument is the function name and arguments, in standard C notation.\n\
-The result is printed and saved in the value history, if it is not void.");
+The argument is the function name and arguments, in the notation of the\n\
+current working language. The result is printed and saved in the value\n\
+history, if it is not void.");
add_cmd ("variable", class_vars, set_command,
"Perform an assignment VAR = EXP.\n\
fputs_filtered (" = ", stream);
print_variable_value (sym, frame, stream);
fprintf_filtered (stream, "\n");
- fflush (stream);
}
}
return values_printed;
local_hex_string(SYMBOL_VALUE_ADDRESS (sym)));
fprintf_filtered (stream, " in file %s, line %d\n",
sal.symtab->filename, sal.line);
- fflush (stream);
}
}
return values_printed;
or 0 if nothing was printed because we have no info
on the function running in FRAME. */
-static int
+static void
print_frame_local_vars (frame, stream)
register FRAME frame;
register FILE *stream;
if (block == 0)
{
fprintf_filtered (stream, "No symbol table info available.\n");
- fflush (stream);
- return 0;
+ return;
}
while (block != 0)
if (!values_printed)
{
fprintf_filtered (stream, "No locals.\n");
- fflush (stream);
}
-
- return 1;
}
/* Same, but print labels. */
-static int
+static void
print_frame_label_vars (frame, this_level_only, stream)
register FRAME frame;
int this_level_only;
if (block == 0)
{
fprintf_filtered (stream, "No symbol table info available.\n");
- fflush (stream);
- return 0;
+ return;
}
bl = blockvector_for_pc (BLOCK_END (block) - 4, &index);
index++;
}
if (have_default)
- return 1;
+ return;
if (values_printed && this_level_only)
- return 1;
+ return;
/* After handling the function's top-level block, stop.
Don't continue to its superblock, the block of
if (!values_printed && !this_level_only)
{
fprintf_filtered (stream, "No catches.\n");
- fflush (stream);
}
-
- return values_printed;
}
/* ARGSUSED */
print_frame_label_vars (selected_frame, 0, stdout);
}
-static int
+static void
print_frame_arg_vars (frame, stream)
register FRAME frame;
register FILE *stream;
if (func == 0)
{
fprintf_filtered (stream, "No symbol table info available.\n");
- fflush (stream);
- return 0;
+ return;
}
b = SYMBOL_BLOCK_VALUE (func);
b, VAR_NAMESPACE, (int *)NULL, (struct symtab **)NULL);
print_variable_value (sym2, frame, stream);
fprintf_filtered (stream, "\n");
- fflush (stream);
}
}
if (!values_printed)
{
fprintf_filtered (stream, "No arguments.\n");
- fflush (stream);
}
-
- return 1;
}
static void
return frame;
}
-/* The "frame_select" command. With no arg, NOP.
+/* The "select_frame" command. With no arg, NOP.
With arg LEVEL_EXP, select the frame at level LEVEL if it is a
valid level. Otherwise, treat level_exp as an address expression
and select it. See parse_frame_specification for more info on proper
frame expressions. */
+/* ARGSUSED */
static void
-frame_select_command (level_exp, from_tty)
+select_frame_command (level_exp, from_tty)
char *level_exp;
int from_tty;
{
}
/* The "frame" command. With no arg, print selected frame briefly.
- With arg, behaves like frame_select and then prints the selected
+ With arg, behaves like select_frame and then prints the selected
frame. */
static void
char *level_exp;
int from_tty;
{
- frame_select_command (level_exp, from_tty);
+ select_frame_command (level_exp, from_tty);
print_stack_frame (selected_frame, selected_frame_level, 1);
}
add_com_alias ("f", "frame", class_stack, 1);
- add_com ("frame-select", class_stack, frame_select_command,
+ add_com ("select-frame", class_stack, select_frame_command,
"Select a stack frame without printing anything.\n\
An argument specifies the frame to select.\n\
It can be a stack frame number or the address of the frame.\n");