From: John Gilmore Date: Sat, 9 Nov 1991 07:45:36 +0000 (+0000) Subject: Lint and some rs/6000 port. X-Git-Tag: gdb-4_18~23143 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c466820795c1eccb540b676f32c42ff71d592610;p=platform%2Fupstream%2Fbinutils.git Lint and some rs/6000 port. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2154859..1e9cb80 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +Fri Nov 8 23:38:48 1991 John Gilmore (gnu at cygnus.com) + + * command.c: Include param.h. + * defs.h (warning_setup, warning): Declare. + * expprint.c (print_subexp, UNOP_MEMVAL case): Lint. + * inflow.c (new_tty): Use USE_O_NOCTTY #define. + * language.c, printcmd.c (print_scalar_formatted), signame.c, + stack.c: lint. + Thu Nov 7 18:26:15 1991 Steve Chamberlain (sac at rtl.cygnus.com) * Makefile.in: link with libiberty after libreadline, since diff --git a/gdb/command.c b/gdb/command.c index 3c05e6c..a1ce588 100644 --- a/gdb/command.c +++ b/gdb/command.c @@ -17,6 +17,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "defs.h" +#include "param.h" #include "command.h" #include "symtab.h" #include "value.h" diff --git a/gdb/language.c b/gdb/language.c index 31c532c..76509fc 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -41,6 +41,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "target.h" #include "parser-defs.h" +extern volatile void return_to_top_level (); + /* Forward function declarations */ static void set_type_range (); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 7608254..ec96d49 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -24,6 +24,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "frame.h" #include "symtab.h" #include "value.h" +#include "language.h" #include "expression.h" #include "gdbcore.h" #include "gdbcmd.h" @@ -207,6 +208,7 @@ print_formatted (val, format, size) 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; @@ -247,22 +249,26 @@ print_scalar_formatted (valaddr, type, format, size, stream) { /* 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\".", @@ -291,9 +297,9 @@ print_scalar_formatted (valaddr, type, format, size, stream) { /* 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 @@ -301,16 +307,16 @@ print_scalar_formatted (valaddr, type, format, size, stream) 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); @@ -319,16 +325,16 @@ print_scalar_formatted (valaddr, type, format, size, stream) 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); @@ -355,9 +361,9 @@ print_scalar_formatted (valaddr, type, format, size, stream) 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"); @@ -368,7 +374,7 @@ print_scalar_formatted (valaddr, type, format, size, stream) 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; @@ -444,7 +450,8 @@ set_next_address (addr) /* 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 on STREAM, @@ -490,7 +497,7 @@ print_address (addr, 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, " "); } @@ -508,7 +515,7 @@ print_address_demangle (addr, stream, do_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, ""); @@ -634,7 +641,7 @@ print_command_1 (exp, inspect, voidprint) { 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); @@ -732,7 +739,7 @@ output_command (exp, from_tty) format = fmt.format; } - expr = parse_c_expression (exp); + expr = parse_expression (exp); old_chain = make_cleanup (free_current_contents, &expr); val = evaluate_expression (expr); @@ -748,7 +755,7 @@ set_command (exp, from_tty) 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); @@ -786,8 +793,8 @@ address_info (exp, from_tty) 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; @@ -804,7 +811,7 @@ address_info (exp, from_tty) 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: @@ -812,7 +819,7 @@ address_info (exp, from_tty) 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: @@ -840,13 +847,8 @@ address_info (exp, from_tty) 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: @@ -882,7 +884,7 @@ x_command (exp, from_tty) 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. */ @@ -908,10 +910,12 @@ x_command (exp, from_tty) /* 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); @@ -933,7 +937,7 @@ whatis_exp (exp, show) if (exp) { - expr = parse_c_expression (exp); + expr = parse_expression (exp); old_chain = make_cleanup (free_current_contents, &expr); val = evaluate_type (expr); } @@ -960,6 +964,18 @@ whatis_command (exp, from_tty) 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 @@ -967,105 +983,32 @@ ptype_command (typename, from_tty) 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"); -} - -#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 */ enum display_status {disabled, enabled}; @@ -1127,7 +1070,7 @@ display_command (exp, from_tty) } innermost_block = 0; - expr = parse_c_expression (exp); + expr = parse_expression (exp); new = (struct display *) xmalloc (sizeof (struct display)); @@ -1493,22 +1436,10 @@ print_frame_args (func, fi, num, stream) 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: { @@ -1531,11 +1462,24 @@ print_frame_args (func, fi, num, stream) 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, ", "); @@ -1900,7 +1844,8 @@ disassemble_command (arg, from_tty) 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; ) @@ -2016,8 +1961,9 @@ You can see these environment settings with the \"show\" command.", /* "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\ diff --git a/gdb/signame.c b/gdb/signame.c index 57759d7..7f07893 100755 --- a/gdb/signame.c +++ b/gdb/signame.c @@ -54,6 +54,7 @@ static num_abbrev sig_table[NSIG*2]; static int sig_table_nelts = 0; /* Enter signal number NUMBER into the tables with ABBREV and NAME. */ +/* ARGSUSED */ static void init_sig (number, abbrev, name) int number; diff --git a/gdb/stack.c b/gdb/stack.c index 6426701..6153650 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -584,7 +584,6 @@ print_block_frame_locals (b, frame, stream) fputs_filtered (" = ", stream); print_variable_value (sym, frame, stream); fprintf_filtered (stream, "\n"); - fflush (stream); } } return values_printed; @@ -625,7 +624,6 @@ print_block_frame_labels (b, have_default, stream) 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; @@ -639,7 +637,7 @@ print_block_frame_labels (b, have_default, stream) 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; @@ -650,8 +648,7 @@ print_frame_local_vars (frame, stream) if (block == 0) { fprintf_filtered (stream, "No symbol table info available.\n"); - fflush (stream); - return 0; + return; } while (block != 0) @@ -669,15 +666,12 @@ print_frame_local_vars (frame, stream) 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; @@ -695,8 +689,7 @@ print_frame_label_vars (frame, this_level_only, stream) 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); @@ -732,9 +725,9 @@ print_frame_label_vars (frame, this_level_only, stream) 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 @@ -747,10 +740,7 @@ print_frame_label_vars (frame, this_level_only, stream) if (!values_printed && !this_level_only) { fprintf_filtered (stream, "No catches.\n"); - fflush (stream); } - - return values_printed; } /* ARGSUSED */ @@ -772,7 +762,7 @@ catch_info () print_frame_label_vars (selected_frame, 0, stdout); } -static int +static void print_frame_arg_vars (frame, stream) register FRAME frame; register FILE *stream; @@ -787,8 +777,7 @@ print_frame_arg_vars (frame, stream) if (func == 0) { fprintf_filtered (stream, "No symbol table info available.\n"); - fflush (stream); - return 0; + return; } b = SYMBOL_BLOCK_VALUE (func); @@ -813,17 +802,13 @@ print_frame_arg_vars (frame, stream) 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 @@ -928,14 +913,15 @@ find_relative_frame (frame, level_offset_ptr) 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; { @@ -964,7 +950,7 @@ frame_select_command (level_exp, 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 @@ -972,7 +958,7 @@ frame_command (level_exp, from_tty) 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); } @@ -1159,7 +1145,7 @@ a command file or a user-defined command."); 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");